Browse Source

Add broadcast flag to withdraw

patch-3
jl777 7 years ago
parent
commit
8f0c81d755
  1. 2
      iguana/exchanges/LP_commands.c
  2. 20
      iguana/exchanges/LP_transaction.c
  3. 4
      iguana/exchanges/LP_utxo.c

2
iguana/exchanges/LP_commands.c

@ -118,7 +118,7 @@ inventory(coin, reset=0, [passphrase=])\n\
lastnonce()\n\
buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce)\n\
sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce)\n\
withdraw(coin, outputs[])\n\
withdraw(coin, outputs[], broadcast=0)\n\
sendrawtransaction(coin, signedtx)\n\
swapstatus(pending=0, fast=0)\n\
swapstatus(coin, limit=10)\n\

20
iguana/exchanges/LP_transaction.c

@ -1521,7 +1521,7 @@ char *LP_opreturndecrypt(void *ctx,char *symbol,bits256 utxotxid,char *passphras
char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
{
static void *ctx;
int32_t allocated_outputs=0,iter,i,utxovout,autofee,completed=0,maxV,numvins,numvouts,datalen,suppress_pubkeys; bits256 privkey; struct LP_address *ap; char changeaddr[64],vinaddr[64],str[65],*signedtx=0,*rawtx=0; struct vin_info *V; uint32_t locktime; cJSON *retjson,*item,*outputs,*vins=0,*txobj=0,*privkeys=0; struct iguana_msgtx msgtx; bits256 utxotxid,signedtxid; uint64_t txfee,newtxfee=10000;
int32_t broadcast,allocated_outputs=0,iter,i,utxovout,autofee,completed=0,maxV,numvins,numvouts,datalen,suppress_pubkeys; bits256 privkey; struct LP_address *ap; char changeaddr[64],vinaddr[64],str[65],*signret,*signedtx=0,*rawtx=0; struct vin_info *V; uint32_t locktime; cJSON *retjson,*item,*outputs,*vins=0,*txobj=0,*privkeys=0; struct iguana_msgtx msgtx; bits256 utxotxid,signedtxid; uint64_t txfee,newtxfee=10000;
//printf("withdraw.%s %s\n",coin->symbol,jprint(argjson,0));
if ( coin->etomic[0] != 0 )
{
@ -1530,6 +1530,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
}
if ( ctx == 0 )
ctx = bitcoin_ctx();
broadcast = jint(argjson,"broadcast");
if ( (outputs= jarray(&numvouts,argjson,"outputs")) == 0 )
{
if ( jstr(argjson,"opreturn") == 0 )
@ -1592,7 +1593,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
printf("incomplete signing withdraw (%s)\n",jprint(vins,0));
if ( signedtx != 0 )
free(signedtx), signedtx = 0;
} //else printf("LP_withdraw.%s %s -> %s\n",coin->symbol,jprint(argjson,0),bits256_str(str,signedtxid));
}
if ( signedtx == 0 )
break;
datalen = (int32_t)strlen(signedtx) / 2;
@ -1621,7 +1622,6 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
{
if ( completed == 0 && (numvins= cJSON_GetArraySize(vins)) > 0 )
{
for (i=0; i<numvins; i++)
{
item = jitem(vins,i);
@ -1634,9 +1634,23 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
free_json(privkeys);
retjson = cJSON_CreateObject();
if ( rawtx != 0 )
{
jaddstr(retjson,"rawtx",rawtx);
free(rawtx);
}
if ( signedtx != 0 )
{
jaddstr(retjson,"hex",signedtx);
if ( broadcast != 0 )
{
if ( (signret= LP_sendrawtransaction(coin->symbol,signedtx)) != 0 )
{
printf("LP_withdraw.%s %s -> %s (%s)\n",coin->symbol,jprint(argjson,0),bits256_str(str,signedtxid),signret);
free(signret);
}
}
free(signedtx);
}
if ( txobj != 0 )
jadd(retjson,"tx",txobj);
jaddbits256(retjson,"txid",signedtxid);

4
iguana/exchanges/LP_utxo.c

@ -537,7 +537,9 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
}
LP_address_utxoadd(1,now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1);
if ( (up= LP_address_utxofind(coin,coin->smartaddr,txid,vout)) == 0 )
printf("couldnt find just added %s/%d ht.%d %.8f\n",bits256_str(str,txid),vout,height,dstr(value));
{
//printf("couldnt find just added %s/%d ht.%d %.8f\n",bits256_str(str,txid),vout,height,dstr(value));
}
else
{
m++;

Loading…
Cancel
Save