bitclientVOut_t* bitclient_addTransactionOutput(bitclientTransaction_t* tx) { bitclientVOut_t* vout = (bitclientVOut_t*)malloc(sizeof(bitclientVOut_t)+2*1024); memset(vout, 0, sizeof(bitclientVOut_t)+2*1024); vout->scriptPkData = (uint8*)(vout+1); simpleList_add(tx->tx_out,vout); return vout; }
bitclientVIn_t* bitclient_addTransactionInput(bitclientTransaction_t* tx) { bitclientVIn_t* vin = (bitclientVIn_t*)malloc(sizeof(bitclientVIn_t)+2*1024); memset(vin, 0, sizeof(bitclientVIn_t)+2*1024); vin->scriptSignatureData = (uint8*)(vin+1); simpleList_add(tx->tx_in, vin); return vin; }
/* * Called when the server detects a new incoming connection */ void jsonRpcServer_newClient(jsonRpcServer_t* jrs, SOCKET s) { // alloc client struct jsonRpcClient_t* client = (jsonRpcClient_t*)malloc(sizeof(jsonRpcClient_t)); memset(client, 0, sizeof(jsonRpcClient_t)); // init client client->jsonRpcServer = jrs; client->clientSocket = s; // set socket as non-blocking #ifdef _WIN32 unsigned int nonblocking=1; unsigned int cbRet; WSAIoctl(s, FIONBIO, &nonblocking, sizeof(nonblocking), NULL, 0, (LPDWORD)&cbRet, NULL, NULL); #else fcntl(s, F_SETFL, O_NONBLOCK); //TODO: not sure what to do about the recv buffer passed to WSAIoctl here.. #endif // init recv buffer client->recvIndex = 0; client->recvSize = JSON_INITIAL_RECV_BUFFER_SIZE; client->recvBuffer = (uint8*)malloc(JSON_INITIAL_RECV_BUFFER_SIZE); // add to client list simpleList_add(jrs->list_connections, client); }