jl777 8 years ago
parent
commit
6e40df23d1
  1. 7
      iguana/iguana_notary.c
  2. 2
      iguana/iguana_payments.c
  3. 6
      iguana/iguana_sign.c
  4. 10
      iguana/swaps/iguana_BTCswap.c
  5. 2
      includes/iguana_funcs.h

7
iguana/iguana_notary.c

@ -413,7 +413,7 @@ int32_t dpow_message_most(uint8_t *k_masks,int32_t num,cJSON *json,int32_t lastf
cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_entry notaries[DPOW_MAXRELAYS],int32_t numnotaries,int32_t height,int32_t lastk,uint64_t mask,int32_t usesigs,bits256 hashmsg,bits256 btctxid)
{
int32_t i,j,m=0; char scriptstr[256]; cJSON *txobj=0,*vins=0,*item; uint64_t satoshis; uint8_t script[35];
int32_t i,j,m=0,siglen; char scriptstr[256]; cJSON *txobj=0,*vins=0,*item; uint64_t satoshis; uint8_t script[35],*sig;
if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,0,1,0)) != 0 )
{
vins = cJSON_CreateArray();
@ -430,14 +430,17 @@ cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_entry no
script[34] = 0xac;
init_hexbytes_noT(scriptstr,script,35);
jaddstr(item,"scriptPubKey",scriptstr);
sig = 0, siglen = 0;
if ( usesigs != 0 && notaries[i].siglen > 0 )
{
init_hexbytes_noT(scriptstr,notaries[i].sig,notaries[i].siglen);
jaddstr(item,"scriptSig",scriptstr);
printf("sig%d.(%s)\n",i,scriptstr);
sig = notaries[i].sig;
siglen = notaries[i].siglen;
}
jaddi(vins,item);
bitcoin_txinput(coin,txobj,notaries[i].prev_hash,notaries[i].prev_vout,0xffffffff,script,sizeof(script),0,0,0,0);
bitcoin_txinput(coin,txobj,notaries[i].prev_hash,notaries[i].prev_vout,0xffffffff,script,sizeof(script),0,0,0,0,sig,siglen);
m++;
if ( m == numnotaries/2+1 && i == lastk )
break;

2
iguana/iguana_payments.c

@ -1140,7 +1140,7 @@ cJSON *iguana_createvins(struct supernet_info *myinfo,struct iguana_info *coin,c
else sequenceid = 0xffffffff;
}
jaddnum(newvin,"sequence",sequenceid);
bitcoin_txinput(coin,txobj,txid,vout,sequenceid,spendscript,spendlen,redeemscript,p2shlen,0,0);
bitcoin_txinput(coin,txobj,txid,vout,sequenceid,spendscript,spendlen,redeemscript,p2shlen,0,0,0,0);
jadd(newvin,"pubkeys",pubkeys);
jaddi(newvins,newvin);
}

6
iguana/iguana_sign.c

@ -1205,12 +1205,14 @@ cJSON *iguana_pubkeysjson(uint8_t *pubkeyptrs[],int32_t numpubkeys)
return(pubkeysjson);
}
cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys)
cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys,uint8_t *sig,int32_t siglen)
{
cJSON *item,*vins; char p2shscriptstr[IGUANA_MAXSCRIPTSIZE*2+1]; uint8_t *script,len;
vins = jduplicate(jobj(txobj,"vin"));
jdelete(txobj,"vin");
item = cJSON_CreateObject();
if ( sig != 0 && siglen > 0 )
iguana_addscript(coin,item,sig,siglen,"scriptSig");
if ( spendscript != 0 && spendscript > 0 )
{
iguana_addscript(coin,item,spendscript,spendlen,"scriptPubKey");
@ -1375,7 +1377,7 @@ P2SH_SPENDAPI(iguana,spendmsig,activecoin,vintxid,vinvout,destaddress,destamount
decode_hex(pubkeys[2],(int32_t)strlen(pubC)>>1,pubC);
pubkeyptrs[2] = pubkeys[2];
}
bitcoin_txinput(active,txobj,vintxid,vinvout,0xffffffff,spendscript,spendlen,V.p2shscript,V.p2shlen,pubkeyptrs,N);
bitcoin_txinput(active,txobj,vintxid,vinvout,0xffffffff,spendscript,spendlen,V.p2shscript,V.p2shlen,pubkeyptrs,N,0,0);
bitcoin_address(msigaddr,active->chain->p2shtype,V.p2shscript,V.p2shlen);
retjson = cJSON_CreateObject();
if ( bitcoin_verifyvins(active,height,&signedtxid,&signedtx,&msgtx,serialized,sizeof(serialized),&V,SIGHASH_ALL,1,V.suppress_pubkeys) == 0 )

10
iguana/swaps/iguana_BTCswap.c

@ -164,7 +164,7 @@ void iguana_addinputs(struct iguana_info *coin,struct bitcoin_spend *spend,cJSON
break;
pubkeyptrs[j] = spend->inputs[i].pubkeys[j];
}
bitcoin_txinput(coin,txobj,spend->inputs[i].txid,spend->inputs[i].vout,spend->inputs[i].sequence,spend->inputs[i].spendscript,spend->inputs[i].spendlen,spend->inputs[i].p2shscript,spend->inputs[i].p2shlen,j>0?pubkeyptrs:0,j);
bitcoin_txinput(coin,txobj,spend->inputs[i].txid,spend->inputs[i].vout,spend->inputs[i].sequence,spend->inputs[i].spendscript,spend->inputs[i].spendlen,spend->inputs[i].p2shscript,spend->inputs[i].p2shlen,j>0?pubkeyptrs:0,j,0,0);
}
}
@ -1235,7 +1235,7 @@ char *instantdex_bailintx(struct iguana_info *coin,bits256 *txidp,struct bitcoin
bitcoin_txoutput(coin,txobj,changescript,scriptv2len,change);
for (i=0; i<spend->numinputs; i++)
bitcoin_txinput(coin,txobj,spend->inputs[i].txid,spend->inputs[i].vout,0xffffffff);
rawtxstr = bitcoin_json2hex(coin,&txid,txobj,0);
rawtxstr = bitcoin_json2hex(coin,&txid,txobj,0,0,0);
char str[65]; printf("%s_bailin.%s (%s)\n",isbob!=0?"bob":"alice",bits256_str(str,txid),rawtxstr);
V = calloc(spend->numinputs,sizeof(*V));
for (i=0; i<spend->numinputs; i++)
@ -1296,8 +1296,8 @@ char *instantdex_payouttx(struct iguana_info *coin,char *sigstr,int32_t *siglenp
{
struct vin_info V; cJSON *txobj;
txobj = instantdex_bailinspend(coin,sharedprivs[1],amount);
bitcoin_txinput(coin,txobj,bailintxid,0,0xffffffff);
bitcoin_txinput(coin,txobj,bailintxid,1,0xffffffff);
bitcoin_txinput(coin,txobj,bailintxid,0,0xffffffff,0,0);
bitcoin_txinput(coin,txobj,bailintxid,1,0xffffffff,0,0);
memset(&V,0,sizeof(V));
if ( othersigstr != 0 )
{
@ -1323,7 +1323,7 @@ char *instantdex_refundtx(struct iguana_info *coin,bits256 *txidp,bits256 bailin
{
char sigstr[256]; int32_t siglen; struct vin_info V; cJSON *txobj;
txobj = instantdex_bailinspend(coin,priv2,amount - txfee);
bitcoin_txinput(coin,txobj,bailintxid,0,0xffffffff);
bitcoin_txinput(coin,txobj,bailintxid,0,0xffffffff,0,0);
return(instantdex_bailinsign(coin,bailinpriv,sigstr,&siglen,txidp,&V,txobj,isbob));
}

2
includes/iguana_funcs.h

@ -308,7 +308,7 @@ bits256 iguana_genesis(struct supernet_info *myinfo,struct iguana_info *coin,str
cJSON *bitcoin_txcreate(int32_t isPoS,int64_t locktime,uint32_t txversion,uint32_t timestamp);
cJSON *bitcoin_txoutput(cJSON *txobj,uint8_t *paymentscript,int32_t len,uint64_t satoshis);
cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys);
cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys,uint8_t *sigscript,int32_t siglen);
int32_t bitcoin_changescript(struct iguana_info *coin,uint8_t *changescript,int32_t n,uint64_t *changep,char *changeaddr,uint64_t inputsatoshis,uint64_t satoshis,uint64_t txfee);
//cJSON *bitcoin_addinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys);

Loading…
Cancel
Save