|
@ -117,7 +117,7 @@ int32_t basilisk_bobscript(uint8_t *rmd160,uint8_t *redeemscript,int32_t *redeem |
|
|
|
|
|
|
|
|
int32_t basilisk_alicescript(uint8_t *redeemscript,int32_t *redeemlenp,uint8_t *script,int32_t n,char *msigaddr,uint8_t altps2h,bits256 pubAm,bits256 pubBn) |
|
|
int32_t basilisk_alicescript(uint8_t *redeemscript,int32_t *redeemlenp,uint8_t *script,int32_t n,char *msigaddr,uint8_t altps2h,bits256 pubAm,bits256 pubBn) |
|
|
{ |
|
|
{ |
|
|
uint8_t i,p2sh160[20]; struct vin_info V; |
|
|
uint8_t p2sh160[20]; struct vin_info V; |
|
|
memset(&V,0,sizeof(V)); |
|
|
memset(&V,0,sizeof(V)); |
|
|
memcpy(&V.signers[0].pubkey[1],pubAm.bytes,sizeof(pubAm)), V.signers[0].pubkey[0] = 0x02; |
|
|
memcpy(&V.signers[0].pubkey[1],pubAm.bytes,sizeof(pubAm)), V.signers[0].pubkey[0] = 0x02; |
|
|
memcpy(&V.signers[1].pubkey[1],pubBn.bytes,sizeof(pubBn)), V.signers[1].pubkey[0] = 0x03; |
|
|
memcpy(&V.signers[1].pubkey[1],pubBn.bytes,sizeof(pubBn)), V.signers[1].pubkey[0] = 0x03; |
|
@ -125,9 +125,9 @@ int32_t basilisk_alicescript(uint8_t *redeemscript,int32_t *redeemlenp,uint8_t * |
|
|
*redeemlenp = bitcoin_MofNspendscript(p2sh160,redeemscript,n,&V); |
|
|
*redeemlenp = bitcoin_MofNspendscript(p2sh160,redeemscript,n,&V); |
|
|
bitcoin_address(msigaddr,altps2h,p2sh160,sizeof(p2sh160)); |
|
|
bitcoin_address(msigaddr,altps2h,p2sh160,sizeof(p2sh160)); |
|
|
n = bitcoin_p2shspend(script,0,p2sh160); |
|
|
n = bitcoin_p2shspend(script,0,p2sh160); |
|
|
for (i=0; i<*redeemlenp; i++) |
|
|
//for (i=0; i<*redeemlenp; i++)
|
|
|
printf("%02x",redeemscript[i]); |
|
|
// printf("%02x",redeemscript[i]);
|
|
|
printf(" <- redeemscript alicetx\n"); |
|
|
//printf(" <- redeemscript alicetx\n");
|
|
|
return(n); |
|
|
return(n); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -212,7 +212,7 @@ int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct b |
|
|
bitcoin_priv2wif(wifstr,*privkey2,rawtx->coin->chain->wiftype); |
|
|
bitcoin_priv2wif(wifstr,*privkey2,rawtx->coin->chain->wiftype); |
|
|
jaddistr(privkeys,wifstr); |
|
|
jaddistr(privkeys,wifstr); |
|
|
V[0].N = V[0].M = 2; |
|
|
V[0].N = V[0].M = 2; |
|
|
char str[65]; printf("add second privkey.(%s) %s\n",jprint(privkeys,0),bits256_str(str,*privkey2)); |
|
|
//char str[65]; printf("add second privkey.(%s) %s\n",jprint(privkeys,0),bits256_str(str,*privkey2));
|
|
|
} else V[0].N = V[0].M = 1; |
|
|
} else V[0].N = V[0].M = 1; |
|
|
V[0].suppress_pubkeys = dest->suppress_pubkeys; |
|
|
V[0].suppress_pubkeys = dest->suppress_pubkeys; |
|
|
if ( dest->redeemlen != 0 ) |
|
|
if ( dest->redeemlen != 0 ) |
|
@ -247,7 +247,7 @@ int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct b |
|
|
jaddi(vins,item); |
|
|
jaddi(vins,item); |
|
|
jdelete(txobj,"vin"); |
|
|
jdelete(txobj,"vin"); |
|
|
jadd(txobj,"vin",vins); |
|
|
jadd(txobj,"vin",vins); |
|
|
printf("basilisk_rawtx_sign locktime.%u/%u for %s spendscript.%s -> %s, suppress.%d\n",rawtx->locktime,dest->locktime,rawtx->name,hexstr,dest->name,dest->suppress_pubkeys); |
|
|
//printf("basilisk_rawtx_sign locktime.%u/%u for %s spendscript.%s -> %s, suppress.%d\n",rawtx->locktime,dest->locktime,rawtx->name,hexstr,dest->name,dest->suppress_pubkeys);
|
|
|
txobj = bitcoin_txoutput(txobj,dest->spendscript,dest->spendlen,dest->amount); |
|
|
txobj = bitcoin_txoutput(txobj,dest->spendscript,dest->spendlen,dest->amount); |
|
|
if ( (rawtxbytes= bitcoin_json2hex(myinfo,rawtx->coin,&dest->txid,txobj,V)) != 0 ) |
|
|
if ( (rawtxbytes= bitcoin_json2hex(myinfo,rawtx->coin,&dest->txid,txobj,V)) != 0 ) |
|
|
{ |
|
|
{ |
|
@ -404,7 +404,7 @@ int32_t basilisk_verify_bobpaid(struct supernet_info *myinfo,void *ptr,uint8_t * |
|
|
|
|
|
|
|
|
int32_t basilisk_alicepayment_spend(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *dest) |
|
|
int32_t basilisk_alicepayment_spend(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *dest) |
|
|
{ |
|
|
{ |
|
|
printf("alicepayment_spend\n"); |
|
|
//printf("alicepayment_spend\n");
|
|
|
swap->alicepayment.spendlen = basilisk_alicescript(swap->alicepayment.redeemscript,&swap->alicepayment.redeemlen,swap->alicepayment.spendscript,0,swap->alicepayment.destaddr,swap->alicecoin->chain->p2shtype,swap->pubAm,swap->pubBn); |
|
|
swap->alicepayment.spendlen = basilisk_alicescript(swap->alicepayment.redeemscript,&swap->alicepayment.redeemlen,swap->alicepayment.spendscript,0,swap->alicepayment.destaddr,swap->alicecoin->chain->p2shtype,swap->pubAm,swap->pubBn); |
|
|
return(basilisk_rawtx_sign(myinfo,swap->alicecoin->blocks.hwmchain.height,swap,dest,&swap->alicepayment,swap->privAm,&swap->privBn,0,0)); |
|
|
return(basilisk_rawtx_sign(myinfo,swap->alicecoin->blocks.hwmchain.height,swap,dest,&swap->alicepayment,swap->privAm,&swap->privBn,0,0)); |
|
|
} |
|
|
} |
|
|