diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 64fc9bf5e..f5a01a598 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1637,6 +1637,42 @@ char *LP_createblasttransaction(uint64_t *changep,int32_t *changeoutp,cJSON **tx return(rawtxbytes); } +char *bitcoin_signrawtransaction(int32_t *completedp,bits256 *signedtxidp,struct iguana_info *coin,char *rawtx,char *wifstr) +{ + char *retstr,*paramstr,*nullarray,*signedtx = 0; cJSON *retjson,*array,*params,signedjson; + *completedp = 0; + memset(signedtxidp,0,sizeof(*signedtxidp)); + params = cJSON_CreateArray(); + jaddistr(params,rawtx); + nullarray = cJSON_CreateArray(); + jaddi(params,nullarray); + array = cJSON_CreateArray(); + jaddstr(array,wifstr); + paramstr = jprint(params,1); + if ( (retstr= bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,"signrawtransaction",paramstr)) != 0 ) + { + if ( (signedjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (hexstr= jstr(json,"hex")) != 0 ) + { + len = (int32_t)strlen(hexstr); + signedtx = calloc(1,len+1); + strcpy(signedtx,hexstr); + *completedp = is_cJSON_True(jobj(json,"complete")); + len >>= 1; + data = malloc(len); + decode_hex(data,len,hexstr); + *signedtxidp = bits256_calctxid(coin->symbol,data,len); + free(data); + } + free_json(signedjson); + } + free(retstr); + } + free(paramstr); + return(signedtx); +} + char *LP_txblast(struct iguana_info *coin,cJSON *argjson) { static void *ctx; @@ -1669,7 +1705,8 @@ char *LP_txblast(struct iguana_info *coin,cJSON *argjson) completed = 0; memset(&msgtx,0,sizeof(msgtx)); memset(signedtxid.bytes,0,sizeof(signedtxid)); - if ( (completed= iguana_signrawtransaction(ctx,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&msgtx,&signedtx,&signedtxid,&V,1,rawtx,vins,privkeys,coin->zcash)) < 0 ) + if ( (signedtx= bitcoin_signrawtransaction(&completed,&signedtxidcoin,rawtx,wifstr)) == 0 ) + //if ( (completed= iguana_signrawtransaction(ctx,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&msgtx,&signedtx,&signedtxid,&V,1,rawtx,vins,privkeys,coin->zcash)) < 0 ) printf("LP_txblast: couldnt sign blast tx %s\n",bits256_str(str,signedtxid)); else if ( completed == 0 ) {