|
|
@ -294,10 +294,13 @@ bits256 basilisk_swap_broadcast(char *name,struct supernet_info *myinfo,struct b |
|
|
|
|
|
|
|
int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct basilisk_swap *swap,struct basilisk_rawtx *dest,struct basilisk_rawtx *rawtx,bits256 privkey,bits256 *privkey2,uint8_t *userdata,int32_t userdatalen,int32_t ignore_cltverr) |
|
|
|
{ |
|
|
|
char *rawtxbytes=0,*signedtx=0,hexstr[999],wifstr[128]; cJSON *txobj,*vins,*item,*sobj,*privkeys; int32_t needsig=1,retval = -1; struct vin_info *V; uint32_t locktime=0; |
|
|
|
char *rawtxbytes=0,*signedtx=0,hexstr[999],wifstr[128]; cJSON *txobj,*vins,*item,*sobj,*privkeys; int32_t needsig=1,retval = -1; uint32_t timestamp; struct vin_info *V; uint32_t locktime=0; |
|
|
|
V = calloc(16,sizeof(*V)); |
|
|
|
timestamp = swap->started; |
|
|
|
if ( dest == &swap->aliceclaim ) |
|
|
|
locktime = swap->locktime + INSTANTDEX_LOCKTIME; |
|
|
|
locktime = (timestamp + INSTANTDEX_LOCKTIME + 3); |
|
|
|
else if ( dest == &swap->bobreclaim ) |
|
|
|
locktime = (timestamp + 2*INSTANTDEX_LOCKTIME + 3); |
|
|
|
V[0].signers[0].privkey = privkey; |
|
|
|
bitcoin_pubkey33(myinfo->ctx,V[0].signers[0].pubkey,privkey); |
|
|
|
privkeys = cJSON_CreateArray(); |
|
|
@ -316,7 +319,7 @@ int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct b |
|
|
|
V[0].ignore_cltverr = ignore_cltverr; |
|
|
|
if ( dest->redeemlen != 0 ) |
|
|
|
memcpy(V[0].p2shscript,dest->redeemscript,dest->redeemlen), V[0].p2shlen = dest->redeemlen; |
|
|
|
txobj = bitcoin_txcreate(rawtx->coin->chain->isPoS,locktime,userdata == 0 ? 1 : 1);//rawtx->coin->chain->locktime_txversion);
|
|
|
|
txobj = bitcoin_txcreate(rawtx->coin->chain->isPoS,locktime,userdata == 0 ? 1 : 1,timestamp);//rawtx->coin->chain->locktime_txversion);
|
|
|
|
vins = cJSON_CreateArray(); |
|
|
|
item = cJSON_CreateObject(); |
|
|
|
if ( userdata != 0 && userdatalen > 0 ) |
|
|
@ -329,7 +332,7 @@ int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct b |
|
|
|
#ifdef DISABLE_CHECKSIG |
|
|
|
needsig = 0; |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
if ( bits256_nonz(rawtx->actualtxid) != 0 ) |
|
|
|
jaddbits256(item,"txid",rawtx->actualtxid); |
|
|
|
else jaddbits256(item,"txid",rawtx->signedtxid); |
|
|
@ -669,7 +672,7 @@ int32_t basilisk_rawtx_return(struct supernet_info *myinfo,int32_t height,struct |
|
|
|
return(retval); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t iambob,int32_t lockinputs,struct basilisk_rawtx *rawtx,uint32_t locktime,uint8_t *script,int32_t scriptlen,int64_t txfee,int32_t minconf) |
|
|
|
int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t iambob,int32_t lockinputs,struct basilisk_rawtx *rawtx,uint32_t locktime,uint8_t *script,int32_t scriptlen,int64_t txfee,int32_t minconf,int32_t delay) |
|
|
|
{ |
|
|
|
char *retstr,scriptstr[1024]; uint32_t basilisktag; int32_t flag,i,n,retval = -1; cJSON *valsobj,*retarray=0; struct vin_info *V; |
|
|
|
//bitcoin_address(coinaddr,rawtx->coin->chain->pubtype,myinfo->persistent_pubkey33,33);
|
|
|
@ -689,7 +692,7 @@ int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilis |
|
|
|
jaddnum(valsobj,"minconf",minconf); |
|
|
|
jaddnum(valsobj,"locktime",locktime); |
|
|
|
jaddnum(valsobj,"timeout",30000); |
|
|
|
jaddnum(valsobj,"timestamp",swap->started); |
|
|
|
jaddnum(valsobj,"timestamp",swap->started+delay); |
|
|
|
rawtx->locktime = locktime; |
|
|
|
//printf("%s locktime.%u\n",rawtx->name,locktime);
|
|
|
|
V = calloc(256,sizeof(*V)); |
|
|
@ -740,7 +743,7 @@ void basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swap * |
|
|
|
{ |
|
|
|
for (i=0; i<3; i++) |
|
|
|
{ |
|
|
|
basilisk_rawtx_gen("payment",myinfo,swap,1,1,&swap->bobpayment,swap->bobpayment.locktime,swap->bobpayment.spendscript,swap->bobpayment.spendlen,swap->bobpayment.coin->chain->txfee,1); |
|
|
|
basilisk_rawtx_gen("payment",myinfo,swap,1,1,&swap->bobpayment,swap->bobpayment.locktime,swap->bobpayment.spendscript,swap->bobpayment.spendlen,swap->bobpayment.coin->chain->txfee,1,0); |
|
|
|
if ( swap->bobpayment.txbytes == 0 || swap->bobpayment.spendlen == 0 ) |
|
|
|
{ |
|
|
|
printf("error bob generating %p payment.%d\n",swap->bobpayment.txbytes,swap->bobpayment.spendlen); |
|
|
@ -769,7 +772,7 @@ void basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swap * |
|
|
|
{ |
|
|
|
for (i=0; i<3; i++) |
|
|
|
{ |
|
|
|
basilisk_rawtx_gen("deposit",myinfo,swap,1,1,&swap->bobdeposit,swap->bobdeposit.locktime,swap->bobdeposit.spendscript,swap->bobdeposit.spendlen,swap->bobdeposit.coin->chain->txfee,1); |
|
|
|
basilisk_rawtx_gen("deposit",myinfo,swap,1,1,&swap->bobdeposit,swap->bobdeposit.locktime,swap->bobdeposit.spendscript,swap->bobdeposit.spendlen,swap->bobdeposit.coin->chain->txfee,1,0); |
|
|
|
if ( swap->bobdeposit.txbytes == 0 || swap->bobdeposit.spendlen == 0 ) |
|
|
|
{ |
|
|
|
printf("error bob generating %p deposit.%d\n",swap->bobdeposit.txbytes,swap->bobdeposit.spendlen); |
|
|
@ -1513,7 +1516,7 @@ void basilisk_sendmostprivs(struct supernet_info *myinfo,struct basilisk_swap *s |
|
|
|
void basilisk_alicepayment(struct supernet_info *myinfo,struct basilisk_swap *swap,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn) |
|
|
|
{ |
|
|
|
alicepayment->spendlen = basilisk_alicescript(alicepayment->redeemscript,&alicepayment->redeemlen,alicepayment->spendscript,0,alicepayment->destaddr,coin->chain->p2shtype,pubAm,pubBn); |
|
|
|
basilisk_rawtx_gen("alicepayment",myinfo,swap,0,1,alicepayment,alicepayment->locktime,alicepayment->spendscript,alicepayment->spendlen,coin->chain->txfee,1); |
|
|
|
basilisk_rawtx_gen("alicepayment",myinfo,swap,0,1,alicepayment,alicepayment->locktime,alicepayment->spendscript,alicepayment->spendlen,coin->chain->txfee,1,0); |
|
|
|
} |
|
|
|
|
|
|
|
// detect insufficient funds/inputs
|
|
|
@ -1615,7 +1618,7 @@ void basilisk_swaploop(void *_swap) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ( basilisk_rawtx_gen("myfee",myinfo,swap,swap->iambob,1,&swap->myfee,0,swap->myfee.spendscript,swap->myfee.spendlen,swap->myfee.coin->chain->txfee,1) == 0 ) |
|
|
|
if ( basilisk_rawtx_gen("myfee",myinfo,swap,swap->iambob,1,&swap->myfee,0,swap->myfee.spendscript,swap->myfee.spendlen,swap->myfee.coin->chain->txfee,1,0) == 0 ) |
|
|
|
{ |
|
|
|
swap->statebits |= basilisk_swapdata_rawtxsend(myinfo,swap,0x80,data,maxlen,&swap->myfee,0x40); |
|
|
|
iguana_unspents_mark(myinfo,swap->iambob!=0?swap->bobcoin:swap->alicecoin,swap->myfee.vins); |
|
|
|