jl777 8 years ago
parent
commit
aa05eb7fbe
  1. 2
      basilisk/basilisk_DEX.c
  2. 2
      iguana/coins/basilisk
  3. 13
      iguana/iguana777.c
  4. 2
      iguana/iguana_peers.c
  5. 54
      iguana/iguana_sign.c
  6. 2
      iguana/tests/decoderawtransaction

2
basilisk/basilisk_DEX.c

@ -499,7 +499,7 @@ STRING_ARG(InstantDEX,available,source)
}
retjson = cJSON_CreateObject();
jaddnum(retjson,"result",dstr(total));
printf("(%s) n.%d total %.8f (%s)\n",jprint(unspents,0),n,dstr(total),jprint(retjson,0));
printf(" n.%d total %.8f (%s)\n",n,dstr(total),jprint(retjson,0));
return(jprint(retjson,1));
}
printf("InstantDEX_available: need to unlock wallet\n");

2
iguana/coins/basilisk

@ -2,5 +2,5 @@ curl --url "http://127.0.0.1:7778" --data "{\"poll\":100,\"active\":1,\"agent\":
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":8333}"
#curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":11,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9334,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}"
curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":18,\"endpend\":18,\"services\":129,\"maxpeers\":256,\"newcoin\":\"SYS\",\"name\":\"SYScoin\",\"hasheaders\":0,\"useaddmultisig\":0,\"netmagic\":\"f9beb4d9\",\"p2p\":8369,\"rpc\":8370,\"pubval\":0,\"p2shval\":5,\"wifval\":128,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"0000072d66e51ab87de265765cc8bdd2d229a4307c672a1b3d5af692519cf765\",\"genesis\":{\"version\":1,\"timestamp\":1450473723,\"nBits\":\"1e0ffff0\",\"nonce\":5258726,\"merkle_root\":\"5215c5a2af9b63f2550b635eb2b354bb13645fd8fa31275394eb161944303065\"},\"protover\":70012,\"auxpow\":1,\"fixit\":0}"
#curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":18,\"endpend\":18,\"services\":129,\"maxpeers\":256,\"newcoin\":\"SYS\",\"name\":\"SYScoin\",\"hasheaders\":0,\"useaddmultisig\":0,\"netmagic\":\"f9beb4d9\",\"p2p\":8369,\"rpc\":8370,\"pubval\":0,\"p2shval\":5,\"wifval\":128,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"0000072d66e51ab87de265765cc8bdd2d229a4307c672a1b3d5af692519cf765\",\"genesis\":{\"version\":1,\"timestamp\":1450473723,\"nBits\":\"1e0ffff0\",\"nonce\":5258726,\"merkle_root\":\"5215c5a2af9b63f2550b635eb2b354bb13645fd8fa31275394eb161944303065\"},\"protover\":70012,\"auxpow\":1,\"fixit\":0}"

13
iguana/iguana777.c

@ -880,18 +880,21 @@ void iguana_coinloop(void *arg)
if ( coin->started == 0 && coin->active != 0 )
{
iguana_callcoinstart(myinfo,coin);
if ( 0 && strcmp("BTC",coin->symbol) == 0 )
if ( strcmp("BTC",coin->symbol) == 0 )
{
char *txstr = "0100000001d378ebd1b0c230b4d078288cf95fe28d7b3032d28c47de22ed6140d845dcb01f00000000d147304402204dd322834ff15cf1526dae3940521bb504b365b194515725d9c0f81dfbeae68d02205fb8fd269e3f2ddf7d0a17b056d2904ce572b8f22edeb39cd4c209fcf5244645011d74c7e7d8a2041be600e74708276d79ff001e754269b6e868ccf517f87f3d004c674c6763040cd6e557b175210326af93b75917b4903d7acdf8e2a560357ce18b7615cc7de02ade4f62861a57dfac67a9149c41c06aac6a7fcfd29eef87c4a633b9126b8b09882102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac68ffffffff01127b0000000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000";
cJSON *txobj = cJSON_Parse("{\"version\":1,\"locktime\":1474666158,\"vin\":[{\"userdata\":\"51\",\"txid\":\"fc97c3675c83c09723e0b14292ddec73820cb7352166ace4fe81ed62568315f2\",\"vout\":0,\"scriptPubKey\":{\"hex\":\"a914b7a2e599edb55d3f78ebcbfd49e82dd9a12adc2487\"},\"suppress\":1,\"sequence\":0,\"redeemScript\":\"6304ae9ee557b1752102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac67a914adfad35d6646a0514011ba6ab53462319b651f96882103225046c9947222ab04acdefe2ed5dec4dcb593c5e6ae58e2c61c7ace14d81b70ac68\"}],\"vout\":[{\"satoshis\":\"36042\",\"scriptPubkey\":{\"hex\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}}]}");
struct vin_info V[3]; bits256 txid,checktxid; uint8_t *extraspace; struct iguana_info *coin = iguana_coinfind("BTC");
cJSON *txobj2 = cJSON_Parse("{\"version\":1,\"locktime\":0,\"vin\":[{\"userdata\":\"20491d74c7e7d8a2041be600e74708276d79ff001e754269b6e868ccf517f87f3d00\",\"txid\":\"1fb0dc45d84061ed22de478cd232307b8de25ff98c2878d0b430c2b0d1eb78d3\",\"vout\":0,\"scriptPubKey\":{\"hex\":\"a9144bf88c2ce8b9a40e3863bf1d4a5fb443d3e1bfe487\"},\"suppress\":1,\"redeemScript\":\"63040cd6e557b175210326af93b75917b4903d7acdf8e2a560357ce18b7615cc7de02ade4f62861a57dfac67a9149c41c06aac6a7fcfd29eef87c4a633b9126b8b09882102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac68\"}],\"vout\":[{\"satoshis\":\"31506\",\"scriptPubkey\":{\"hex\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}}]}");
cJSON *txobj3 = cJSON_Parse("{\"version\":1,\"timestamp\":1474672690,\"vin\":[{\"sequence\":4294967214,\"txid\":\"119ec1a65f530c751e53b4af0505e960cf47680859c5f3ee3981ebe883207186\",\"vout\":0,\"scriptSig\":{\"hex\":\"483045022100880a1e3eafade4d4a24dd0bde2f31178d43978beacd63da1ee54760e0651f3b2022061dd05a66b65dc40fb729d95d2205dbf054ceb0bc4eb55c42088d0684a4c5a6701483045022100b4498798fc3a61de0b6df83ea4f6b67f89c5683124c2a3a981bd070826d7d1590220121d73d362b796583baa73c8c78eb851f78dc8f1cc75cb5bb3dfb14d6b843742012102ed1e99e73093c70c6156bce5954cb3e04215405ac06aa525ff942b74b8416efc2103a013a5f01afb3f0f00a657bb76fb30fd38437c80b52d9248b50738c96902e78747522102ed1e99e73093c70c6156bce5954cb3e04215405ac06aa525ff942b74b8416efc2103a013a5f01afb3f0f00a657bb76fb30fd38437c80b52d9248b50738c96902e78752ae\",\"asm\":\"3045022100880a1e3eafade4d4a24dd0bde2f31178d43978beacd63da1ee54760e0651f3b2022061dd05a66b65dc40fb729d95d2205dbf054ceb0bc4eb55c42088d0684a4c5a6701 3045022100b4498798fc3a61de0b6df83ea4f6b67f89c5683124c2a3a981bd070826d7d1590220121d73d362b796583baa73c8c78eb851f78dc8f1cc75cb5bb3dfb14d6b84374201 02ed1e99e73093c70c6156bce5954cb3e04215405ac06aa525ff942b74b8416efc 03a013a5f01afb3f0f00a657bb76fb30fd38437c80b52d9248b50738c96902e787 522102ed1e99e73093c70c6156bce5954cb3e04215405ac06aa525ff942b74b8416efc2103a013a5f01afb3f0f00a657bb76fb30fd38437c80b52d9248b50738c96902e78752ae\"}}],\"numvins\":1}");
struct vin_info V[3]; bits256 txid,checktxid; uint8_t *extraspace; struct iguana_info *coin = iguana_coinfind("BTCD");
memset(V,0,sizeof(V));
char *txbytes = bitcoin_json2hex(myinfo,coin,&txid,txobj,V);
char *txbytes = bitcoin_json2hex(myinfo,coin,&txid,txobj3,V);
printf("rawtx.(%s)\n",txbytes);
extraspace = calloc(1,65536);
txobj = bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&checktxid,0,txbytes,extraspace,65536,0,jobj(txobj,"vin"),1);
txobj = bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&checktxid,0,txbytes,extraspace,65536,0,jobj(txobj2,"vin"),1);
printf("TXOBJ.(%s)\n",jprint(txobj,0));
free(extraspace);
getchar();
//getchar();
}
}
now = (uint32_t)time(NULL);

2
iguana/iguana_peers.c

@ -905,7 +905,7 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr)
for (i=n=0; i<IGUANA_MAXPEERS; i++)
if ( strcmp(ipaddr,coin->peers->active[i].ipaddr) == 0 )
{
printf("%s possible peer.(%s) %x already there\n",coin->symbol,ipaddr,(uint32_t)coin->peers->active[i].ipbits);
//printf("%s possible peer.(%s) %x already there\n",coin->symbol,ipaddr,(uint32_t)coin->peers->active[i].ipbits);
return(0);
}
//printf("%s Q possible.(%s)\n",coin->symbol,ipaddr);

54
iguana/iguana_sign.c

@ -71,7 +71,6 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
}
if ( (p2shlen= msg->p2shlen) > 0 && msg->redeemscript != 0 )
{
//printf("p2shlen.%d %x\n",p2shlen,p2shlen);
if ( p2shlen < 76 )
serialized[len++] = p2shlen;
else if ( p2shlen <= 0xff )
@ -86,6 +85,12 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
serialized[len++] = ((p2shlen >> 8) & 0xff);
} else return(-1);
memcpy(&serialized[len],msg->redeemscript,p2shlen), len += p2shlen;
{
int32_t j;
for (j=0; j<p2shlen; j++)
printf("%02x",msg->redeemscript[j]);
printf(" p2shlen.%d %x\n",p2shlen,p2shlen);
}
}
}
//printf("sequence starts.%d\n",len);
@ -178,7 +183,7 @@ int32_t iguana_parsehexstr(uint8_t **destp,uint16_t *lenp,uint8_t *dest2,int32_t
int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_msgvin *vin,cJSON *vinobj,struct vin_info *V)
{
struct iguana_outpoint outpt; struct iguana_waddress *waddr; struct iguana_waccount *wacct; uint8_t lastbyte,spendscript[8192]; uint32_t tmp=0; int32_t i,n,starti,spendlen,suppress_pubkeys,siglen,plen,m,endi,rwflag=1,need_op0=0,len = 0; char *userdata=0,*pubkeystr,*hexstr = 0,*redeemstr = 0,*spendstr = 0; cJSON *scriptjson = 0,*obj,*pubkeysjson = 0;
struct iguana_outpoint outpt; struct iguana_waddress *waddr; struct iguana_waccount *wacct; uint8_t lastbyte,spendscript[8192]; uint32_t tmp=0; int32_t i,n,starti,spendlen,suppress_pubkeys,siglen,plen,m,endi,rwflag=1,len = 0; char *userdata=0,*pubkeystr,*hexstr = 0,*redeemstr = 0,*spendstr = 0; cJSON *scriptjson = 0,*obj,*pubkeysjson = 0;
//printf("PARSEVIN.(%s) vin.%p\n",jprint(vinobj,0),vin);
if ( V == 0 )
memset(vin,0,sizeof(*vin));
@ -199,8 +204,8 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
{
spendstr = jstr(obj,"hex");
lastbyte = _decode_hex(&spendstr[strlen(spendstr)-2]);
if ( lastbyte == SCRIPT_OP_CHECKMULTISIG )
need_op0 = 1;
//if ( lastbyte == SCRIPT_OP_CHECKMULTISIG )
// need_op0 = 1;
if ( V != 0 )
{
V->spendlen = (int32_t)strlen(spendstr) >> 1;
@ -214,8 +219,8 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
{
redeemstr = jstr(obj,"hex");
lastbyte = _decode_hex(&redeemstr[strlen(redeemstr)-2]);
if ( lastbyte == SCRIPT_OP_CHECKMULTISIG )
need_op0 = 1;
//if ( lastbyte == SCRIPT_OP_CHECKMULTISIG )
// need_op0 = 1;
}
}
if ( (userdata= jstr(vinobj,"userdata")) == 0 || is_hexstr(userdata,(int32_t)strlen(userdata)) <= 0 )
@ -251,29 +256,36 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
len += iguana_rwvarint32(rwflag,&serialized[len],&tmp);
endi = len;
//printf("rwflag.%d len.%d tmp.%d\n",rwflag,len,tmp);
if ( need_op0 != 0 )
serialized[len++] = 0; // hack for bug for bug backward compatibility
//if ( need_op0 != 0 )
// serialized[len++] = 0; // hack for bug for bug backward compatibility
if ( hexstr != 0 )
{
n = (int32_t)strlen(hexstr) >> 1;
//printf("add.(%s) offset.%d\n",hexstr,len);
vin->vinscript = &serialized[len];
decode_hex(&serialized[len],n,hexstr);
vin->scriptlen = n + need_op0;
vin->scriptlen = n;// + need_op0;
if ( V != 0 )
{
i = m = 0;
while ( m < n )
{
siglen = serialized[len + m++];
if ( i == 0 && m == 1 && siglen == 0 ) // multisig backward compatible
continue;
memcpy(V->signers[i].sig,&serialized[len + m],siglen);
//if ( i == 0 && m == 1 && siglen == 0 ) // multisig backward compatible
// continue;
if ( serialized[len + m + siglen - 1] == SIGHASH_ALL )
memcpy(V->signers[i++].sig,&serialized[len + m],siglen);
{
int32_t j;
for (j=0; j<siglen; j++)
printf("%02x",serialized[len + m + j]);
printf(" (%d)\n",siglen);
}
m += siglen;
i++;
}
if ( m != n )
printf("ERROR: len.%d n.%d i.%d\n",m,n,i);
printf("ERROR: (%s) len.%d n.%d i.%d\n",hexstr,m,n,i);
}
len += n;
} //else printf("iguana_parsevinobj: hex script missing (%s)\n",jprint(vinobj,0));
@ -357,11 +369,21 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
}
//printf("len.%d tmp.%d output sequence.[%d] <- %x\n",len,tmp,len,vin->sequence);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(vin->sequence),&vin->sequence);
if ( 0 && spendstr != 0 )
if ( spendstr != 0 )
{
if ( vin->spendlen == 0 )
{
vin->spendlen = (int32_t)strlen(spendstr) >> 1;
decode_hex(vin->spendscript,vin->spendlen,spendstr);
}
if ( V != 0 && V->spendlen == 0 )
{
V->spendlen = (int32_t)strlen(spendstr) >> 1;
decode_hex(V->spendscript,V->spendlen,spendstr);
}
//printf("serialized.%p len.%d\n",serialized,len);
n = iguana_parsehexstr(&vin->spendscript,&vin->spendlen,V!=0?V->spendscript:0,V!=0?&V->spendlen:0,&serialized[len],spendstr);
len += n;
//n = iguana_parsehexstr(&vin->spendscript,&vin->spendlen,V!=0?V->spendscript:0,V!=0?&V->spendlen:0,&serialized[len],spendstr);
//len += n;
}
return(len);
}

2
iguana/tests/decoderawtransaction

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"010000006dace557013155fe9a842de866684908683863c1142c2949f455d1a6353984ae06a9aac5a400000000904730440220356242c03f0245137e34cb113861da6c3c4c2c56adb8e215f9f822a078558743022035679f0b44b9d2472270eec78ffa7452addff29146a31801003661a940aa817701473044022048bd70d9e1b3cf57b0fee2e67e15666f1498aef5d114280b13f7ac8c0df7c96c022036b7a6528ed36e342e456d77e62a0a95edffa91f9321f11d5b95ed20c7f8fe6d01ffffffff01706f9800000000001976a9148ee61a3161993f4f7b7081259bf5f3322d65d3f888ac00000000\", 1]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000032b8e5570186712083e8eb8139eef3c559086847cf60e90505afb4531e750c535fa6c19e1100000000fd1e0100483045022100880a1e3eafade4d4a24dd0bde2f31178d43978beacd63da1ee54760e0651f3b2022061dd05a66b65dc40fb729d95d2205dbf054ceb0bc4eb55c42088d0684a4c5a6701483045022100b4498798fc3a61de0b6df83ea4f6b67f89c5683124c2a3a981bd070826d7d1590220121d73d362b796583baa73c8c78eb851f78dc8f1cc75cb5bb3dfb14d6b843742012102ed1e99e73093c70c6156bce5954cb3e04215405ac06aa525ff942b74b8416efc2103a013a5f01afb3f0f00a657bb76fb30fd38437c80b52d9248b50738c96902e78747522102ed1e99e73093c70c6156bce5954cb3e04215405ac06aa525ff942b74b8416efc2103a013a5f01afb3f0f00a657bb76fb30fd38437c80b52d9248b50738c96902e78752aeffffffff01706f9800000000001976a9148ee61a3161993f4f7b7081259bf5f3322d65d3f888ac00000000\", 1]}"

Loading…
Cancel
Save