|
@ -755,9 +755,9 @@ int32_t _basilisk_rawtx_sign(char *symbol,uint8_t pubtype,uint8_t p2shtype,uint8 |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,char *symbol,uint8_t pubtype,uint8_t p2shtype,uint8_t isPoS,uint8_t wiftype,void *ctx,bits256 privkey,bits256 *privkey2p,uint8_t *redeemscript,int32_t redeemlen,uint8_t *userdata,int32_t userdatalen,bits256 utxotxid,int32_t vout,uint8_t *pubkey33,int32_t finalseqid,uint32_t expiration,int64_t *destamountp,uint64_t satoshis,char *changeaddr) |
|
|
char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,char *symbol,uint8_t pubtype,uint8_t p2shtype,uint8_t isPoS,uint8_t wiftype,void *ctx,bits256 privkey,bits256 *privkey2p,uint8_t *redeemscript,int32_t redeemlen,uint8_t *userdata,int32_t userdatalen,bits256 utxotxid,int32_t vout,char *destaddr,uint8_t *pubkey33,int32_t finalseqid,uint32_t expiration,int64_t *destamountp,uint64_t satoshis,char *changeaddr) |
|
|
{ |
|
|
{ |
|
|
char *rawtxbytes=0,*signedtx=0,str[65],hexstr[999],wifstr[128],destaddr[64]; uint8_t spendscript[512],addrtype,rmd160[20]; cJSON *utxoobj,*txobj,*vins,*item,*privkeys; int32_t completed,spendlen,ignore_cltverr=1,suppress_pubkeys=1; struct vin_info *V; uint32_t timestamp,locktime = 0,sequenceid = 0xffffffff * finalseqid; bits256 txid; uint64_t destamount,change = 0; |
|
|
char *rawtxbytes=0,*signedtx=0,str[65],hexstr[999],wifstr[128],_destaddr[64]; uint8_t spendscript[512],addrtype,rmd160[20]; cJSON *utxoobj,*txobj,*vins,*item,*privkeys; int32_t completed,spendlen,ignore_cltverr=1,suppress_pubkeys=1; struct vin_info *V; uint32_t timestamp,locktime = 0,sequenceid = 0xffffffff * finalseqid; bits256 txid; uint64_t destamount,change = 0; |
|
|
*destamountp = 0; |
|
|
*destamountp = 0; |
|
|
memset(signedtxidp,0,sizeof(*signedtxidp)); |
|
|
memset(signedtxidp,0,sizeof(*signedtxidp)); |
|
|
if ( finalseqid == 0 ) |
|
|
if ( finalseqid == 0 ) |
|
@ -819,7 +819,11 @@ char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,ch |
|
|
jaddbits256(item,"txid",utxotxid); |
|
|
jaddbits256(item,"txid",utxotxid); |
|
|
jaddnum(item,"vout",vout); |
|
|
jaddnum(item,"vout",vout); |
|
|
//sobj = cJSON_CreateObject();
|
|
|
//sobj = cJSON_CreateObject();
|
|
|
bitcoin_address(destaddr,pubtype,pubkey33,33); |
|
|
if ( destaddr == 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
destaddr = _destaddr; |
|
|
|
|
|
bitcoin_address(destaddr,pubtype,pubkey33,33); |
|
|
|
|
|
} |
|
|
bitcoin_addr2rmd160(&addrtype,rmd160,destaddr); |
|
|
bitcoin_addr2rmd160(&addrtype,rmd160,destaddr); |
|
|
/*int32_t i;
|
|
|
/*int32_t i;
|
|
|
for (i=0; i<33; i++) |
|
|
for (i=0; i<33; i++) |
|
@ -854,7 +858,6 @@ char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,ch |
|
|
bitcoin_addr2rmd160(&changetype,changermd160,changeaddr); |
|
|
bitcoin_addr2rmd160(&changetype,changermd160,changeaddr); |
|
|
changelen = bitcoin_standardspend(changescript,0,changermd160); |
|
|
changelen = bitcoin_standardspend(changescript,0,changermd160); |
|
|
txobj = bitcoin_txoutput(txobj,changescript,changelen,change); |
|
|
txobj = bitcoin_txoutput(txobj,changescript,changelen,change); |
|
|
printf("add change.(%s)\n",jprint(txobj,0)); |
|
|
|
|
|
} |
|
|
} |
|
|
if ( (rawtxbytes= bitcoin_json2hex(isPoS,&txid,txobj,V)) != 0 ) |
|
|
if ( (rawtxbytes= bitcoin_json2hex(isPoS,&txid,txobj,V)) != 0 ) |
|
|
{ |
|
|
{ |
|
@ -892,7 +895,7 @@ int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pub |
|
|
} |
|
|
} |
|
|
for (iter=0; iter<2; iter++) |
|
|
for (iter=0; iter<2; iter++) |
|
|
{ |
|
|
{ |
|
|
if ( (signedtx= basilisk_swap_bobtxspend(&rawtx->I.signedtxid,iter == 0 ? txfee : newtxfee,str,coin->symbol,coin->pubtype,coin->p2shtype,coin->isPoS,coin->wiftype,ctx,privkey,0,0,0,0,0,rawtx->utxotxid,rawtx->utxovout,pubkey33,1,0,&destamount,rawtx->I.amount,changeaddr)) != 0 ) |
|
|
if ( (signedtx= basilisk_swap_bobtxspend(&rawtx->I.signedtxid,iter == 0 ? txfee : newtxfee,str,coin->symbol,coin->pubtype,coin->p2shtype,coin->isPoS,coin->wiftype,ctx,privkey,0,0,0,0,0,rawtx->utxotxid,rawtx->utxovout,rawtx->I.destaddr,pubkey33,1,0,&destamount,rawtx->I.amount,changeaddr)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
rawtx->I.datalen = (int32_t)strlen(signedtx) >> 1; |
|
|
rawtx->I.datalen = (int32_t)strlen(signedtx) >> 1; |
|
|
if ( rawtx->I.datalen <= sizeof(rawtx->txbytes) ) |
|
|
if ( rawtx->I.datalen <= sizeof(rawtx->txbytes) ) |
|
@ -931,7 +934,7 @@ int32_t basilisk_rawtx_sign(char *symbol,uint8_t pubtype,uint8_t p2shtype,uint8_ |
|
|
} |
|
|
} |
|
|
for (iter=0; iter<2; iter++) |
|
|
for (iter=0; iter<2; iter++) |
|
|
{ |
|
|
{ |
|
|
if ( (signedtx= basilisk_swap_bobtxspend(&rawtx->I.signedtxid,iter == 0 ? txfee : newtxfee,rawtx->name,symbol,pubtype,p2shtype,isPoS,wiftype,swap->ctx,privkey,privkey2,0,0,userdata,userdatalen,rawtx->utxotxid,rawtx->utxovout,rawtx->pubkey33,1,0,&destamount,rawtx->I.amount,changeaddr)) != 0 ) |
|
|
if ( (signedtx= basilisk_swap_bobtxspend(&rawtx->I.signedtxid,iter == 0 ? txfee : newtxfee,rawtx->name,symbol,pubtype,p2shtype,isPoS,wiftype,swap->ctx,privkey,privkey2,0,0,userdata,userdatalen,rawtx->utxotxid,rawtx->utxovout,rawtx->I.destaddr,rawtx->pubkey33,1,0,&destamount,rawtx->I.amount,changeaddr)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
rawtx->I.datalen = (int32_t)strlen(signedtx) >> 1; |
|
|
rawtx->I.datalen = (int32_t)strlen(signedtx) >> 1; |
|
|
if ( rawtx->I.datalen <= sizeof(rawtx->txbytes) ) |
|
|
if ( rawtx->I.datalen <= sizeof(rawtx->txbytes) ) |
|
@ -987,7 +990,7 @@ char *basilisk_swap_Aspend(char *name,char *symbol,uint8_t pubtype,uint8_t p2sht |
|
|
for (i=0; i<32; i++) |
|
|
for (i=0; i<32; i++) |
|
|
privBn.bytes[i] = rev.bytes[31 - i];*/ |
|
|
privBn.bytes[i] = rev.bytes[31 - i];*/ |
|
|
txfee = LP_txfee(symbol); |
|
|
txfee = LP_txfee(symbol); |
|
|
signedtx = basilisk_swap_bobtxspend(&signedtxid,txfee,name,symbol,pubtype,p2shtype,isPoS,wiftype,ctx,privAm,&privBn,redeemscript,redeemlen,0,0,utxotxid,vout,pubkey33,1,expiration,destamountp,0,0); |
|
|
signedtx = basilisk_swap_bobtxspend(&signedtxid,txfee,name,symbol,pubtype,p2shtype,isPoS,wiftype,ctx,privAm,&privBn,redeemscript,redeemlen,0,0,utxotxid,vout,0,pubkey33,1,expiration,destamountp,0,0); |
|
|
} |
|
|
} |
|
|
return(signedtx); |
|
|
return(signedtx); |
|
|
} |
|
|
} |
|
|