Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
4ade6b63d0
  1. 22
      basilisk/basilisk_swap.c
  2. 4
      iguana/iguana_interpreter.c
  3. 5
      iguana/iguana_payments.c
  4. 2
      iguana/iguana_realtime.c
  5. 4
      iguana/iguana_volatiles.c
  6. 2
      iguana/iguana_wallet.c
  7. 2
      iguana/tests/walletpassphrase

22
basilisk/basilisk_swap.c

@ -78,6 +78,7 @@ int32_t basilisk_bobscript(uint8_t *script,int32_t n,uint32_t *locktimep,int32_t
pubkeyA[0] = 0x03; pubkeyA[0] = 0x03;
pubkeyB[0] = 0x02; pubkeyB[0] = 0x02;
} }
char str[65]; printf("bobtx dflag.%d %s\n",depositflag,bits256_str(str,cltvpub));
if ( bits256_nonz(cltvpub) == 0 || bits256_nonz(destpub) == 0 ) if ( bits256_nonz(cltvpub) == 0 || bits256_nonz(destpub) == 0 )
return(-1); return(-1);
for (i=0; i<20; i++) for (i=0; i<20; i++)
@ -113,19 +114,27 @@ int32_t basilisk_alicescript(uint8_t *script,int32_t n,char *msigaddr,uint8_t al
int32_t basilisk_rawtx_spend(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *dest,struct basilisk_rawtx *rawtx,bits256 privkey,bits256 *privkey2,uint8_t *userdata,int32_t userdatalen) int32_t basilisk_rawtx_spend(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *dest,struct basilisk_rawtx *rawtx,bits256 privkey,bits256 *privkey2,uint8_t *userdata,int32_t userdatalen)
{ {
char *rawtxbytes,*signedtx,hexstr[999],wifstr[128]; cJSON *txobj,*vins,*item,*sobj,*privkeys; int32_t retval = -1; struct vin_info V; char *rawtxbytes,*signedtx,hexstr[999],wifstr[128]; cJSON *txobj,*vins,*item,*sobj,*privkeys; int32_t retval = -1; struct vin_info V; uint32_t locktime=0;
memset(&V,0,sizeof(V)); memset(&V,0,sizeof(V));
if ( dest == &swap->aliceclaim )
locktime = swap->locktime + INSTANTDEX_LOCKTIME;
V.signers[0].privkey = privkey; V.signers[0].privkey = privkey;
privkeys = cJSON_CreateArray(); privkeys = cJSON_CreateArray();
bitcoin_priv2wif(wifstr,privkey,rawtx->coin->chain->wiftype); bitcoin_priv2wif(wifstr,privkey,rawtx->coin->chain->wiftype);
jaddistr(privkeys,wifstr); jaddistr(privkeys,wifstr);
if ( privkey2 != 0 )
{
V.signers[1].privkey = *privkey2;
bitcoin_priv2wif(wifstr,*privkey2,rawtx->coin->chain->wiftype);
jaddistr(privkeys,wifstr);
}
if ( userdata != 0 && userdatalen > 0 ) if ( userdata != 0 && userdatalen > 0 )
{ {
V.suppress_pubkeys = rawtx->suppress_pubkeys; V.suppress_pubkeys = rawtx->suppress_pubkeys;
memcpy(V.userdata,userdata,userdatalen); memcpy(V.userdata,userdata,userdatalen);
V.userdatalen = userdatalen; V.userdatalen = userdatalen;
} }
txobj = bitcoin_txcreate(rawtx->coin->chain->isPoS,0,1); txobj = bitcoin_txcreate(rawtx->coin->chain->isPoS,locktime,rawtx->coin->chain->locktime_txversion);
vins = cJSON_CreateArray(); vins = cJSON_CreateArray();
item = cJSON_CreateObject(); item = cJSON_CreateObject();
if ( bits256_nonz(rawtx->actualtxid) != 0 ) if ( bits256_nonz(rawtx->actualtxid) != 0 )
@ -136,10 +145,12 @@ int32_t basilisk_rawtx_spend(struct supernet_info *myinfo,struct basilisk_swap *
init_hexbytes_noT(hexstr,rawtx->spendscript,rawtx->spendlen); init_hexbytes_noT(hexstr,rawtx->spendscript,rawtx->spendlen);
jaddstr(sobj,"hex",hexstr); jaddstr(sobj,"hex",hexstr);
jadd(item,"scriptPubKey",sobj); jadd(item,"scriptPubKey",sobj);
if ( locktime != 0 )
jaddnum(item,"sequence",0);
jaddi(vins,item); jaddi(vins,item);
jdelete(txobj,"vin"); jdelete(txobj,"vin");
jadd(txobj,"vin",vins); jadd(txobj,"vin",vins);
printf("basilisk_rawtx_spend for %s spendscript.%s -> %s\n",rawtx->name,hexstr,dest->name); printf("basilisk_rawtx_spend locktime.%u/%u for %s spendscript.%s -> %s\n",rawtx->locktime,dest->locktime,rawtx->name,hexstr,dest->name);
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 )
{ {
@ -195,6 +206,7 @@ int32_t basilisk_rawtx_spendscript(struct supernet_info *myinfo,struct basilisk_
} }
if ( (txobj= bitcoin_data2json(rawtx->coin,&rawtx->signedtxid,&rawtx->msgtx,rawtx->extraspace,sizeof(rawtx->extraspace),rawtx->txbytes,rawtx->datalen)) != 0 ) if ( (txobj= bitcoin_data2json(rawtx->coin,&rawtx->signedtxid,&rawtx->msgtx,rawtx->extraspace,sizeof(rawtx->extraspace),rawtx->txbytes,rawtx->datalen)) != 0 )
{ {
rawtx->locktime = rawtx->msgtx.lock_time;
if ( (vouts= jarray(&n,txobj,"vout")) != 0 && v < n ) if ( (vouts= jarray(&n,txobj,"vout")) != 0 && v < n )
{ {
vout = jitem(vouts,v); vout = jitem(vouts,v);
@ -418,6 +430,8 @@ int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilis
jaddnum(valsobj,"minconf",minconf); jaddnum(valsobj,"minconf",minconf);
jaddnum(valsobj,"locktime",locktime); jaddnum(valsobj,"locktime",locktime);
jaddnum(valsobj,"timeout",30000); jaddnum(valsobj,"timeout",30000);
rawtx->locktime = locktime;
printf("%s locktime.%u\n",rawtx->name,locktime);
if ( (retstr= basilisk_rawtx(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,valsobj,"")) != 0 ) if ( (retstr= basilisk_rawtx(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,valsobj,"")) != 0 )
{ {
//printf("%s got.(%s)\n",str,retstr); //printf("%s got.(%s)\n",str,retstr);
@ -664,6 +678,7 @@ int32_t basilisk_verify_choosei(struct supernet_info *myinfo,struct basilisk_swa
swap->pubA0.bytes[i] = data[len++]; swap->pubA0.bytes[i] = data[len++];
for (i=0; i<32; i++) for (i=0; i<32; i++)
swap->pubA1.bytes[i] = data[len++]; swap->pubA1.bytes[i] = data[len++];
char str[65]; printf("GOT pubA0/1 %s\n",bits256_str(str,swap->pubA0));
} }
else else
{ {
@ -844,6 +859,7 @@ void basilisk_swaploop(void *_swap)
data[datalen++] = swap->pubA0.bytes[i]; data[datalen++] = swap->pubA0.bytes[i];
for (i=0; i<32; i++) for (i=0; i<32; i++)
data[datalen++] = swap->pubA1.bytes[i]; data[datalen++] = swap->pubA1.bytes[i];
char str[65]; printf("SEND pubA0/1 %s\n",bits256_str(str,swap->pubA0));
} }
swap->statebits |= basilisk_swapsend(myinfo,swap,0x08,data,datalen,0x04); swap->statebits |= basilisk_swapsend(myinfo,swap,0x08,data,datalen,0x04);
} }

4
iguana/iguana_interpreter.c

@ -498,7 +498,7 @@ static int32_t iguana_pushdata(struct iguana_interpreter *stacks,int64_t num64,u
struct iguana_stackdata Snum; cJSON *item = 0; char tmpstr[2048]; int32_t num = (int32_t)num64; struct iguana_stackdata Snum; cJSON *item = 0; char tmpstr[2048]; int32_t num = (int32_t)num64;
if ( stacks->lastpath[stacks->ifdepth] < 0 ) if ( stacks->lastpath[stacks->ifdepth] < 0 )
return(0); return(0);
printf("PUSH.(%lld %p %d\n",(long long)num64,numbuf,numlen); printf("PUSH.(%lld %p %d)\n",(long long)num64,numbuf,numlen);
if ( stacks->maxstackdepth > 0 ) if ( stacks->maxstackdepth > 0 )
{ {
/*if ( numbuf != 0 ) /*if ( numbuf != 0 )
@ -817,7 +817,7 @@ int32_t iguana_checkmultisig(struct iguana_info *coin,struct iguana_interpreter
int32_t iguana_checklocktimeverify(struct iguana_info *coin,int64_t tx_lockval,uint32_t nSequence,struct iguana_stackdata Snum) int32_t iguana_checklocktimeverify(struct iguana_info *coin,int64_t tx_lockval,uint32_t nSequence,struct iguana_stackdata Snum)
{ {
int64_t nLockTime = iguana_num(Snum); int64_t nLockTime = iguana_num(Snum);
if ( nLockTime < 0 ) if ( nLockTime < 0 || tx_lockval < 0 )
return(-1); return(-1);
else if ( ((tx_lockval < LOCKTIME_THRESHOLD && nLockTime < LOCKTIME_THRESHOLD) || else if ( ((tx_lockval < LOCKTIME_THRESHOLD && nLockTime < LOCKTIME_THRESHOLD) ||
(tx_lockval >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD)) == 0 ) (tx_lockval >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD)) == 0 )

5
iguana/iguana_payments.c

@ -1023,9 +1023,14 @@ cJSON *iguana_createvins(struct supernet_info *myinfo,struct iguana_info *coin,c
init_hexbytes_noT(scriptstr,redeemscript,p2shlen); init_hexbytes_noT(scriptstr,redeemscript,p2shlen);
jaddstr(newvin,"redeemScript",scriptstr); jaddstr(newvin,"redeemScript",scriptstr);
} }
if ( jint(txobj,"locktime") > 0 )
sequenceid = (uint32_t)time(NULL); // any value < 0xfffffffe should be fine
else
{
if ( jobj(item,"sequence") != 0 ) if ( jobj(item,"sequence") != 0 )
sequenceid = juint(item,"sequence"); sequenceid = juint(item,"sequence");
else sequenceid = 0xffffffff; else sequenceid = 0xffffffff;
}
jaddnum(newvin,"sequence",sequenceid); 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);
jadd(newvin,"pubkeys",pubkeys); jadd(newvin,"pubkeys",pubkeys);

2
iguana/iguana_realtime.c

@ -29,7 +29,6 @@ void iguana_RTramchainfree(struct iguana_info *coin,struct iguana_bundle *bp)
bp->ramchain = coin->RTramchain; bp->ramchain = coin->RTramchain;
iguana_mempurge(&coin->RTmem); iguana_mempurge(&coin->RTmem);
iguana_mempurge(&coin->RThashmem); iguana_mempurge(&coin->RThashmem);
coin->RTdatabad = 0;
for (hdrsi=coin->bundlescount-1; hdrsi>0; hdrsi--) for (hdrsi=coin->bundlescount-1; hdrsi>0; hdrsi--)
if ( (bp= coin->bundles[hdrsi]) == 0 && bp != coin->current ) if ( (bp= coin->bundles[hdrsi]) == 0 && bp != coin->current )
{ {
@ -37,6 +36,7 @@ void iguana_RTramchainfree(struct iguana_info *coin,struct iguana_bundle *bp)
if ( iguana_volatilesmap(coin,&bp->ramchain) != 0 ) if ( iguana_volatilesmap(coin,&bp->ramchain) != 0 )
printf("error mapping bundle.[%d]\n",hdrsi); printf("error mapping bundle.[%d]\n",hdrsi);
} }
coin->RTdatabad = 0;
printf("done RTramchain\n"); printf("done RTramchain\n");
} }
} }

4
iguana/iguana_volatiles.c

@ -221,10 +221,6 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
coin->spendvectorsaved = 0; coin->spendvectorsaved = 0;
coin->started = 0; coin->started = 0;
coin->active = 0; coin->active = 0;
int32_t i; struct iguana_bundle *bp;
for (i=0; i<coin->bundlescount; i++)
if ( (bp= coin->bundles[i]) != 0 )
iguana_RTramchainfree(coin,bp);
} else printf("volatileupdate error null rdata [%d]\n",spentchain->height/coin->current->bundleheight); } else printf("volatileupdate error null rdata [%d]\n",spentchain->height/coin->current->bundleheight);
return(-1); return(-1);
} }

2
iguana/iguana_wallet.c

@ -1069,8 +1069,10 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout)
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( timeout <= 0 ) if ( timeout <= 0 )
return(clonestr("{\"error\":\"timeout must be positive\"}")); return(clonestr("{\"error\":\"timeout must be positive\"}"));
printf("timeout.%d\n",timeout);
myinfo->expiration = (uint32_t)time(NULL) + timeout; myinfo->expiration = (uint32_t)time(NULL) + timeout;
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,password,permanentfile,0); retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,password,permanentfile,0);
myinfo->expiration = (uint32_t)time(NULL) + timeout;
iguana_walletinitcheck(myinfo,coin); iguana_walletinitcheck(myinfo,coin);
return(retstr); return(retstr);
} }

2
iguana/tests/walletpassphrase

@ -1,2 +1,2 @@
#curl --url "http://127.0.0.1:7778" --data "{\"method\":\"walletpassphrase\",\"params\":[\"test\", 600]}" #curl --url "http://127.0.0.1:7778" --data "{\"method\":\"walletpassphrase\",\"params\":[\"test\", 600]}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"walletpassphrase\",\"password\":\"test\",\"timeout\":300}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"walletpassphrase\",\"password\":\"test\",\"timeout\":86444}"

Loading…
Cancel
Save