From 5669a56c362590fd2fd305784b999e9b72963a98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 22 Aug 2016 15:08:21 -0300 Subject: [PATCH] possible fix for issue 53 --- iguana/iguana_payments.c | 9 +++++---- iguana/iguana_wallet.c | 2 +- iguana/tests/decoderawtransaction | 2 +- iguana/tests/sendtoaddress | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 8bc30aaba..00b68d3f8 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -444,16 +444,17 @@ void iguana_RTunspentslock(struct supernet_info *myinfo,struct iguana_info *coin char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *coinaddr,uint64_t satoshis,uint64_t txfee,char *comment,char *comment2,int32_t minconf,char *account) { - uint8_t addrtype,spendscript[1024],rmd160[20]; int32_t completed; char *retstr,spendscriptstr[4096],*rawtx=0,*signedtx = 0; bits256 signedtxid,senttxid; cJSON *retjson,*vins,*addresses,*valsobj; uint32_t spendlen,locktime = 0; struct iguana_waddress *waddr; uint32_t basilisktag; + uint8_t addrtype,spendscript[1024],rmd160[20]; int32_t completed; char *retstr,spendscriptstr[4096],*rawtx=0,*signedtx = 0; bits256 signedtxid,senttxid; cJSON *retjson,*vins,*addresses,*valsobj; uint32_t spendlen,locktime = 0; uint32_t basilisktag; //sendtoaddress [comment] [comment-to] is a real and is rounded to 8 decimal places. Returns the transaction ID if successful. Y if ( account == 0 || account[0] == 0 ) account = "*"; addresses = iguana_getaddressesbyaccount(myinfo,coin,account); if ( coin->changeaddr[0] == 0 ) { - if ( (waddr= iguana_getaccountaddress(myinfo,coin,0,0,coin->changeaddr,"change")) == 0 ) - return(clonestr("{\"error\":\"no change address specified\"}")); - strcpy(coin->changeaddr,waddr->coinaddr); + //if ( (waddr= iguana_getaccountaddress(myinfo,coin,0,0,coin->changeaddr,"change")) == 0 ) + // return(clonestr("{\"error\":\"no change address specified\"}")); + bitcoin_address(coin->changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33); + printf("%s change %s\n",coin->symbol,coin->changeaddr); } if ( coinaddr != 0 && coinaddr[0] != 0 && satoshis != 0 ) { diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index d511e6343..3d07e16f4 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1094,7 +1094,7 @@ struct iguana_waddress *iguana_getaccountaddress(struct supernet_info *myinfo,st wacct = iguana_waccountcreate(myinfo,account); if ( wacct != 0 ) { - if ( (waddr= wacct->current) == 0 ) + if ( (waddr= wacct->current) == 0 || waddr->numunspents > 0 ) { if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 ) { diff --git a/iguana/tests/decoderawtransaction b/iguana/tests/decoderawtransaction index 957342efc..7ec699bec 100755 --- a/iguana/tests/decoderawtransaction +++ b/iguana/tests/decoderawtransaction @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000ab71aa5701b8b5b227160b1ddff8c851ef1750b4f73b8e24138b931d3befbf5d0b051c6cd200000000904730440220112c68dd9ac6b9f8d81c226b1cc72be7f4e75d9f81db82adf6931d23d45ccf360220266df0681e89fb3f603118a8f3764122eb2a131cbcc1d8cfa61351e1989adf0c0147304402203022147b0ae5135e413cd116db7310942f46bb91cc2dbebd30d814a09fe624d1022022725baa7aaea080c4c050da69bac4c70e7fb9b317190f51d7a3e263affe7d1801ffffffff01706f9800000000001976a91454a752f0d71b89d7c014ed0be29ca231c9546f9f88ac00000000\", 1]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000193cbb570289f3d9a6dbc265caae9eb4c2c1176b546270fa48310da4c3593c8f764e914ec3010000006a473044022006f5fd779b3eec22bef3d204e2b4b9cd2c6de6384b90f42e882011c0dc41eafd0220181e702bc90e8e90ad5d7495f177904a78faacf36ef507f7f4b55d03e9bd55550121020ce8ffc263769bfa15579b2757873ea5690107acfafb6dc1b77cd7057ac38349ffffffff466304197095eeceb34a9b8cc57b34a9d069f37cb3c0aedcb71c5f3c0858afd5010000006a473044022002ff607e81647700daa1960850bec94c42ab11eed7a4a9088257f2358eb7012f022020da58ebcc41a704d466cf3a82494ae838b7f1b8ce6a14e8010ab16abb15ec790121020ce8ffc263769bfa15579b2757873ea5690107acfafb6dc1b77cd7057ac38349ffffffff02804a5d05000000001976a914ec3ed21928ca63954b87eefa887de6464c46d3cc88acf0b6cf01000000001976a91421e112f4211cbc612bc5f3de86acf0017b88b67d88ac00000000\", 1]}" diff --git a/iguana/tests/sendtoaddress b/iguana/tests/sendtoaddress index 254feab04..63021dfda 100755 --- a/iguana/tests/sendtoaddress +++ b/iguana/tests/sendtoaddress @@ -1,2 +1,2 @@ -curl --url "http://127.0.0.1:7778" --data "{\"method\":\"sendtoaddress\",\"params\":[\"RQCP1TcfevTQU35ZftPNx2TZpB9ZkSZQ3S\", 0.001, \"testcomment\", \"sendcomment\"]}" +curl --url "http://127.0.0.1:7778" --data "{\"method\":\"sendtoaddress\",\"params\":[\"RWpLoeTF17e57h2dztWjVtFiPGJN68oWwx\", 0.9, \"testcomment\", \"sendcomment\"]}"