Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
a1a85a54b5
  1. 2
      iguana/exchanges/bitcoin.h
  2. 5
      iguana/iguana777.h
  3. 10
      iguana/iguana_chains.c
  4. 115
      iguana/iguana_payments.c
  5. 2
      iguana/iguana_peers.c
  6. 59
      iguana/iguana_secp.c
  7. 2
      iguana/iguana_sign.c
  8. 2
      iguana/iguana_unspents.c
  9. 4
      iguana/iguana_wallet.c
  10. 2
      iguana/m_unix
  11. 2
      iguana/main.c
  12. 2
      iguana/tests/sendtoaddress
  13. 2
      iguana/tests/signmessageC
  14. 2
      iguana/tests/verifymessage
  15. 2
      iguana/tests/verifymessageB
  16. 2
      iguana/tests/verifymessageC
  17. 8
      includes/iguana_apideclares.h

2
iguana/exchanges/bitcoin.h

@ -76,7 +76,7 @@ char *iguana_scriptget(struct iguana_info *coin,char *scriptstr,char *asmstr,int
int32_t bitcoin_base58decode(uint8_t *data,char *coinaddr);
char *bitcoin_base58encode(char *coinaddr,uint8_t *data_,int32_t datalen);
int32_t bitcoin_sign(void *ctx,uint8_t *sig,bits256 txhash2,bits256 privkey);
int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256 privkey,int32_t recoverable);
int32_t oldbitcoin_verify(uint8_t *sig,int32_t siglen,uint8_t *data,int32_t datalen,uint8_t *pubkey,int32_t len);

5
iguana/iguana777.h

@ -202,7 +202,7 @@ struct iguana_peermsgrequest { struct queueitem DL; struct iguana_peer *addr; bi
struct iguana_chain
{
//const int32_t chain_id;
char name[32],symbol[8];
char name[32],symbol[8],messagemagic[64];
uint8_t pubtype,p2shtype,wiftype,netmagic[4];
char *genesis_hash,*genesis_hex; // hex string
uint16_t portp2p,rpcport;
@ -919,7 +919,7 @@ int32_t iguana_process_msgrequestQ(struct iguana_info *coin);
uint32_t iguana_fastfindinit(struct iguana_info *coin);
int32_t iguana_unspentindfind(struct iguana_info *coin,char *coinaddr,uint8_t *spendscript,int32_t *scriptlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi);
int32_t iguana_addressvalidate(struct iguana_info *coin,uint8_t *addrtypep,uint8_t rmd160[20],char *address);
int32_t bitcoin_sign(void *ctx,uint8_t *sig,bits256 txhash2,bits256 privkey);
int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256 privkey,int32_t recoverable);
bits256 iguana_str2priv(struct supernet_info *myinfo,struct iguana_info *coin,char *str);
int32_t iguana_spentflag(struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,int16_t spent_hdrsi,uint32_t spent_unspentind,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount);
int32_t iguana_voutscript(struct iguana_info *coin,struct iguana_bundle *bp,uint8_t *scriptspace,char *asmstr,struct iguana_unspent *u,struct iguana_pkhash *p,int32_t txi);
@ -946,6 +946,7 @@ struct iguana_waddress *iguana_waddressadd(struct supernet_info *myinfo,struct i
cJSON *iguana_createvins(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *txobj,cJSON *vins);
bits256 bitcoin_pubkey33(void *ctx,uint8_t *data,bits256 privkey);
bits256 bitcoin_randkey(void *ctx);
int32_t bitcoin_recoververify(void *ctx,char *symbol,uint8_t *sig64,bits256 messagehash2,uint8_t *pubkey);
extern int32_t HDRnet,netBLOCKS;

10
iguana/iguana_chains.c

@ -29,7 +29,7 @@ static struct iguana_chain Chains[] =
//[CHAIN_TESTNET3] =
{
//CHAIN_TESTNET3,
"testnet3", "tBTC",
"testnet3", "tBTC", "Bitcoin Signed Message:\n", // strMessageMagic
PUBKEY_ADDRESS_TEST, SCRIPT_ADDRESS_TEST, PRIVKEY_ADDRESS_TEST,
"\x0b\x11\x09\x07",
"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943",
@ -39,7 +39,7 @@ static struct iguana_chain Chains[] =
//[CHAIN_BITCOIN] =
{
//CHAIN_BITCOIN,
"bitcoin", "BTC",
"bitcoin", "BTC", "Bitcoin Signed Message:\n", // strMessageMagic
0, 5, 0x80,
"\xf9\xbe\xb4\xd9",
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
@ -51,7 +51,7 @@ static struct iguana_chain Chains[] =
//[CHAIN_BTCD] =
{
//CHAIN_BTCD,
"btcd", "BTCD",
"btcd", "BTCD", "BitcoinDark Signed Message:\n", // strMessageMagic
PUBKEY_ADDRESS_BTCD, SCRIPT_ADDRESS_BTCD, PRIVKEY_ADDRESS_BTCD,
"\xe4\xc2\xd8\xe6",
"0000044966f40703b516c5af180582d53f783bfd319bb045e2dc3e05ea695d46",
@ -62,7 +62,7 @@ static struct iguana_chain Chains[] =
},
//[CHAIN_VPN] =
{
"vpncoin", "VPN",
"vpncoin", "VPN", "VPNcoin Signed Message:\n", // strMessageMagic
71, 5, 199, // PUBKEY_ADDRESS + SCRIPT_ADDRESS addrman.h, use wif2priv API on any valid wif
"\xfb\xc0\xb6\xdb", // pchMessageStart main.cpp
//"aaea16b9b820180153d9cd069dbfd54764f07cb49c71987163132a72d568cb14",
@ -72,7 +72,7 @@ static struct iguana_chain Chains[] =
},
//[CHAIN_LTC] =
{
"litecoin", "LTC",
"litecoin", "LTC", "Litecoin Signed Message:\n",
0, 5, 176, // PUBKEY_ADDRESS + SCRIPT_ADDRESS addrman.h, use wif2priv API on any valid wif
"\xfb\xc0\xb6\xdb", // pchMessageStart main.cpp
//"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2",

115
iguana/iguana_payments.c

@ -179,6 +179,8 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
STRING_AND_INT(bitcoinrpc,sendrawtransaction,rawtx,allowhighfees)
{
cJSON *retjson = cJSON_CreateObject(); char txidstr[65]; bits256 txid; uint8_t *serialized; struct iguana_peer *addr; int32_t i,len = (int32_t)strlen(rawtx) >> 1;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( coin->peers.numranked >= 8 )
{
serialized = calloc(1,sizeof(struct iguana_msghdr) + len);
@ -197,6 +199,8 @@ STRING_AND_INT(bitcoinrpc,sendrawtransaction,rawtx,allowhighfees)
STRING_ARG(bitcoinrpc,submitblock,rawbytes)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
cJSON *retjson = cJSON_CreateObject();
// send to all peers
return(jprint(retjson,1));
@ -204,6 +208,8 @@ STRING_ARG(bitcoinrpc,submitblock,rawbytes)
ZERO_ARGS(bitcoinrpc,makekeypair)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
bits256 privkey; char str[67]; cJSON *retjson = cJSON_CreateObject();
privkey = rand256(1);
jaddstr(retjson,"result","success");
@ -215,6 +221,8 @@ ZERO_ARGS(bitcoinrpc,makekeypair)
STRING_ARG(bitcoinrpc,validatepubkey,pubkeystr)
{
uint8_t rmd160[20],pubkey[65],addrtype = 0; int32_t plen; char coinaddr[128],*str; cJSON *retjson;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
plen = (int32_t)strlen(pubkeystr) >> 1;
if ( plen >= 33 && plen <= 65 && coin != 0 && coin->chain != 0 )
{
@ -238,6 +246,8 @@ STRING_ARG(bitcoinrpc,validatepubkey,pubkeystr)
STRING_ARG(bitcoinrpc,decodescript,scriptstr)
{
int32_t scriptlen; uint8_t script[IGUANA_MAXSCRIPTSIZE],rmd160[20]; char coinaddr[128],asmstr[IGUANA_MAXSCRIPTSIZE*2+1]; cJSON *scriptobj,*retjson = cJSON_CreateObject();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( scriptstr != 0 && coin != 0 && (scriptlen= (int32_t)strlen(scriptstr)>>1) < sizeof(script) )
{
decode_hex(script,scriptlen,scriptstr);
@ -337,6 +347,8 @@ INT_ARRAY_STRING(bitcoinrpc,addmultisigaddress,M,pubkeys,account) //
HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
{
uint8_t script[IGUANA_MAXSCRIPTSIZE],rmd160[20],pubkey33[33]; char coinaddr[128],asmstr[IGUANA_MAXSCRIPTSIZE*2+1]; struct iguana_bundle *bp; int32_t minconf,scriptlen,unspentind,height,spentheight; int64_t RTspend; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P; struct iguana_txid *T; struct iguana_unspent *U; struct iguana_ramchain *ramchain; cJSON *scriptobj,*retjson = cJSON_CreateObject();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( coin != 0 )
{
minconf = (mempool != 0) ? 0 : 1;
@ -387,33 +399,55 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
return(jprint(retjson,1));
}
TWO_STRINGS(bitcoinrpc,signmessage,address,messagestr)
bits256 iguana_messagehash2(char *message,char *messagemagic)
{
bits256 privkey,hash2; int32_t n,len,siglen; char sigstr[256],sig64str[256]; uint8_t sig[128],*message=0; cJSON *retjson = cJSON_CreateObject();
int32_t n,len; uint8_t *messagebuf; bits256 hash2;
n = (int32_t)strlen(message) >> 1;
len = (int32_t)strlen(messagemagic);
if ( message[0] == '0' && message[1] == 'x' && is_hexstr(message+2,n-2) > 0 )
{
messagebuf = malloc(n-2 + len);
memcpy(messagebuf,messagemagic,len);
decode_hex(messagebuf+len,n-2,message+2);
n--;
}
else
{
n <<= 1;
messagebuf = malloc(n + len + 1);
memcpy(messagebuf,messagemagic,len);
strcpy((void *)&messagebuf[len],message);
//printf("MESSAGE.(%s)\n",(void *)messagebuf);
}
n += len;
hash2 = bits256_doublesha256(0,messagebuf,n);
//for (i=0; i<sizeof(hash2); i++)
// revhash2.bytes[i] = hash2.bytes[sizeof(hash2) - 1 - i];
if ( messagebuf != (void *)message )
free(messagebuf);
return(hash2);
}
TWO_STRINGS(bitcoinrpc,signmessage,address,message)
{
bits256 privkey,hash2; int32_t len,siglen; char sigstr[256],sig65str[256]; uint8_t sig[128]; cJSON *retjson = cJSON_CreateObject();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( coin != 0 )
{
privkey = iguana_str2priv(myinfo,coin,address);
if ( bits256_nonz(privkey) != 0 )
{
n = (int32_t)strlen(messagestr) >> 1;
if ( messagestr[0] == '0' && messagestr[1] == 'x' && is_hexstr(messagestr+2,n-2) > 0 )
{
message = malloc(n-2);
decode_hex(message,n-2,messagestr+2);
n--;
} else message = (uint8_t *)messagestr, n <<= 1;
hash2 = bits256_doublesha256(0,message,n);
if ( (siglen= bitcoin_sign(coin->ctx,sig,hash2,privkey)) > 0 )
hash2 = iguana_messagehash2(message,coin->chain->messagemagic);
if ( (siglen= bitcoin_sign(coin->ctx,coin->symbol,sig,hash2,privkey,1)) > 0 )
{
sigstr[0] = sig64str[0] = 0;
//init_hexbytes_noT(sigstr,sig,siglen);
len = nn_base64_encode(sig,siglen,sig64str,sizeof(sig64str));
sig64str[len++] = '=';
sig64str[len++] = 0;
jaddstr(retjson,"result",sig64str);
sigstr[0] = sig65str[0] = 0;
len = nn_base64_encode(sig,siglen,sig65str,sizeof(sig65str));
sig65str[len] = 0;
jaddstr(retjson,"result",sig65str);
}
if ( message != (void *)messagestr )
free(message);
} else jaddstr(retjson,"error","invalid address (can be wif, wallet address or privkey hex)");
}
return(jprint(retjson,1));
@ -421,13 +455,40 @@ TWO_STRINGS(bitcoinrpc,signmessage,address,messagestr)
THREE_STRINGS(bitcoinrpc,verifymessage,address,sig,message)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
int32_t len,plen; uint8_t sigbuf[256],pubkey[65]; char str[4096]; bits256 hash2; cJSON *retjson = cJSON_CreateObject();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( strlen(sig) < sizeof(sigbuf)*8/6 )
{
len = (int32_t)strlen(sig);
len = nn_base64_decode(sig,len,sigbuf,sizeof(sigbuf));
//int32_t i; for (i=0; i<len; i++)
// printf("%02x",sigbuf[i]);
//printf(" siglen.%d [%d] address.(%s) sig.(%s) message.(%s)\n",len,sigbuf[0],address,sig,message);
hash2 = iguana_messagehash2(message,coin->chain->messagemagic);
if ( bitcoin_recoververify(myinfo->ctx,coin->symbol,sigbuf,hash2,pubkey) == 0 )
jadd(retjson,"result",jtrue());
else jadd(retjson,"result",jfalse());
jaddstr(retjson,"coin",coin->symbol);
jaddstr(retjson,"address",address);
jaddstr(retjson,"message",message);
if ( (plen= bitcoin_pubkeylen(pubkey)) > 0 )
{
init_hexbytes_noT(str,pubkey,plen);
jaddstr(retjson,"pubkey",str);
}
init_hexbytes_noT(str,sigbuf,len);
jaddstr(retjson,"sighex",str);
jaddbits256(retjson,"messagehash",hash2);
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"sig is too long\"}"));
}
HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
{
struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len,height; cJSON *retjson,*txobj;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 )
{
retjson = cJSON_CreateObject();
@ -480,6 +541,8 @@ HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
STRING_ARG(bitcoinrpc,decoderawtransaction,rawtx)
{
cJSON *txobj = 0; bits256 txid;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( rawtx != 0 && rawtx[0] != 0 )
{
if ( (strlen(rawtx) & 1) != 0 )
@ -494,6 +557,8 @@ STRING_ARG(bitcoinrpc,decoderawtransaction,rawtx)
HASH_ARG(bitcoinrpc,gettransaction,txid)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(bitcoinrpc_getrawtransaction(IGUANA_CALLARGS,txid,1));
}
@ -559,6 +624,8 @@ cJSON *iguana_createvins(struct supernet_info *myinfo,struct iguana_info *coin,c
ARRAY_OBJ_INT(bitcoinrpc,createrawtransaction,vins,vouts,locktime)
{
bits256 txid; int32_t offset,spendlen=0,n; uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; uint64_t satoshis; char *hexstr,*field,*txstr; cJSON *txobj,*item,*obj,*retjson = cJSON_CreateObject();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( coin != 0 && (txobj= bitcoin_createtx(coin,locktime)) != 0 )
{
iguana_createvins(myinfo,coin,txobj,vins);
@ -639,6 +706,8 @@ ARRAY_OBJ_INT(bitcoinrpc,createrawtransaction,vins,vouts,locktime)
TWOINTS_AND_ARRAY(bitcoinrpc,listunspent,minconf,maxconf,array)
{
int32_t numrmds; uint8_t *rmdarray; cJSON *retjson = cJSON_CreateArray();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( minconf == 0 )
minconf = 1;
if ( maxconf == 0 )
@ -652,12 +721,16 @@ TWOINTS_AND_ARRAY(bitcoinrpc,listunspent,minconf,maxconf,array)
INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,listlockunspent)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}

2
iguana/iguana_peers.c

@ -832,7 +832,7 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr)
} else printf("ignore.(%s) lastconnect.%u lastkilled.%u numconnects.%d\n",ipaddr,iA->lastconnect,iA->lastkilled,iA->numconnects);
} //else printf("skip.(%s) ind.%d status.%d\n",ipaddr,iA->hh.itemind,iA->status);
} else printf("cant find (%s) which should have been created\n",ipaddr);
} else printf("reject ipaddr.(%s)\n",ipaddr);
} else printf("reject ipaddr.(%s) vs checkaddr.(%s)\n",ipaddr,checkaddr);
}
}
free_queueitem(ipaddr);

59
iguana/iguana_secp.c

@ -19,6 +19,7 @@
#include <stdlib.h>
#include "../includes/curve25519.h"
#include "../../secp256k1-zkp/include/secp256k1.h"
#include "../../secp256k1-zkp/include/secp256k1_recovery.h"
bits256 bitcoin_randkey(secp256k1_context *ctx)
{
@ -70,9 +71,10 @@ bits256 bitcoin_pubkey33(secp256k1_context *ctx,uint8_t *data,bits256 privkey)
return(pubkey);
}
int32_t bitcoin_sign(void *ctx,uint8_t *sig,int32_t maxlen,bits256 txhash2,bits256 privkey)
int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,int32_t maxlen,bits256 txhash2,bits256 privkey,int32_t recoverflag)
{
secp256k1_ecdsa_signature SIG; bits256 extra_entropy,seed; int32_t flag = 0,retval = -1; size_t siglen = 72;
int32_t fCompressed = 1;
secp256k1_ecdsa_signature SIG; secp256k1_ecdsa_recoverable_signature rSIG; bits256 extra_entropy,seed; int32_t flag = 0,recid,retval = -1; size_t siglen = 72; secp256k1_pubkey SECPUB,CHECKPUB;
seed = rand256(0);
extra_entropy = rand256(0);
if ( ctx == 0 )
@ -86,10 +88,33 @@ int32_t bitcoin_sign(void *ctx,uint8_t *sig,int32_t maxlen,bits256 txhash2,bits2
}
if ( secp256k1_context_randomize(ctx,seed.bytes) > 0 )
{
if ( secp256k1_ecdsa_sign(ctx,&SIG,txhash2.bytes,privkey.bytes,secp256k1_nonce_function_rfc6979,extra_entropy.bytes) > 0 )
if ( recoverflag != 0 )
{
if ( secp256k1_ecdsa_signature_serialize_der(ctx,sig,&siglen,&SIG) > 0 )
retval = (int32_t)siglen;
if ( secp256k1_ecdsa_sign_recoverable(ctx,&rSIG,txhash2.bytes,privkey.bytes,secp256k1_nonce_function_rfc6979,extra_entropy.bytes) > 0 )
{
recid = -1;
secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx,sig+1,&recid,&rSIG);
if ( secp256k1_ecdsa_recover(ctx,&SECPUB,&rSIG,txhash2.bytes) > 0 )
{
if ( secp256k1_ec_pubkey_create(ctx,&CHECKPUB,privkey.bytes) > 0 )
{
if ( memcmp(&SECPUB,&CHECKPUB,sizeof(SECPUB)) == 0 )
{
sig[0] = 27 + recid + (fCompressed != 0 ? 4 : 0);
retval = 64 + 1;
}
else printf("secpub mismatch\n");
} else printf("pubkey create error\n");
} else printf("recover error\n");
} else printf("secp256k1_ecdsa_sign_recoverable error\n");
}
else
{
if ( secp256k1_ecdsa_sign(ctx,&SIG,txhash2.bytes,privkey.bytes,secp256k1_nonce_function_rfc6979,extra_entropy.bytes) > 0 )
{
if ( secp256k1_ecdsa_signature_serialize_der(ctx,sig,&siglen,&SIG) > 0 )
retval = (int32_t)siglen;
}
}
}
if ( flag != 0 )
@ -98,6 +123,30 @@ int32_t bitcoin_sign(void *ctx,uint8_t *sig,int32_t maxlen,bits256 txhash2,bits2
return(retval);
}
int32_t bitcoin_recoververify(void *ctx,char *symbol,uint8_t *sig65,bits256 messagehash2,uint8_t *pubkey)
{
size_t plen; int32_t retval = -1,flag = 0; secp256k1_pubkey PUB; secp256k1_ecdsa_signature SIG; secp256k1_ecdsa_recoverable_signature rSIG;
pubkey[0] = 0;
if ( ctx == 0 )
ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY), flag++;
if ( ctx != 0 )
{
plen = (sig65[0] <= 31) ? 65 : 33;
secp256k1_ecdsa_recoverable_signature_parse_compact(ctx,&rSIG,sig65 + 1,0);
secp256k1_ecdsa_recoverable_signature_convert(ctx,&SIG,&rSIG);
if ( secp256k1_ecdsa_recover(ctx,&PUB,&rSIG,messagehash2.bytes) > 0 )
{
secp256k1_ec_pubkey_serialize(ctx,pubkey,&plen,&PUB,plen == 65 ? SECP256K1_EC_UNCOMPRESSED : SECP256K1_EC_COMPRESSED);
if ( secp256k1_ecdsa_verify(ctx,&SIG,messagehash2.bytes,&PUB) > 0 )
retval = 0;
else printf("secp256k1_ecdsa_verify error\n");
} else printf("secp256k1_ecdsa_recover error\n");
if ( flag != 0 )
secp256k1_context_destroy(ctx);
}
return(retval);
}
int32_t bitcoin_verify(void *ctx,uint8_t *sig,int32_t siglen,bits256 txhash2,uint8_t *pubkey,int32_t plen)
{
int32_t flag=0,retval = -1; secp256k1_pubkey PUB; secp256k1_ecdsa_signature SIG;

2
iguana/iguana_sign.c

@ -760,7 +760,7 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,bits256 *signedtxidp,char **
siglen = vp->signers[j].siglen;
if ( bits256_nonz(vp->signers[j].privkey) != 0 )
{
siglen = bitcoin_sign(coin->ctx,sig,sigtxid,vp->signers[j].privkey);
siglen = bitcoin_sign(coin->ctx,coin->symbol,sig,sigtxid,vp->signers[j].privkey,0);
if ( (plen= bitcoin_pubkeylen(vp->signers[j].pubkey)) <= 0 )
bitcoin_pubkey33(coin->ctx,vp->signers[j].pubkey,vp->signers[j].privkey);
sig[siglen++] = sighash;

2
iguana/iguana_unspents.c

@ -137,8 +137,8 @@ struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_r
*ramchainp = ramchain;
*depositsp = ACCTS[pkind].total;
*lastunspentindp = ACCTS[pkind].lastunspentind;
printf("[%d] return pkind.%u of %u P.%p %.8f last.%u ACCTS.%p %p\n",i,pkind,numpkinds,P,dstr(*depositsp),*lastunspentindp,ACCTS,ramchain->A);
*p = P[pkind];
printf("[%d] return pkind.%u %.8f last.%u ACCTS.%p %p\n",i,pkind,dstr(*depositsp),*lastunspentindp,ACCTS,ramchain->A);
return(p);
}
else if ( pkind != 0 )

4
iguana/iguana_wallet.c

@ -618,14 +618,13 @@ uint8_t iguana_waddrvalidate(struct supernet_info *myinfo,struct iguana_info *co
cJSON *iguana_walletiterate(struct supernet_info *myinfo,struct iguana_info *coin,int32_t flag,cJSON *array,int32_t *goodp,int32_t *badp,int32_t *errors)
{
struct iguana_waccount *wacct,*tmp; struct iguana_waddress *waddr,*tmp2; uint8_t errorflags; int32_t i,good=0,bad=0,_errors[8]; cJSON *item;
struct iguana_waccount *wacct,*tmp; struct iguana_waddress *waddr=0,*tmp2; uint8_t errorflags; int32_t i,good=0,bad=0,_errors[8]; cJSON *item;
if ( errors == 0 )
errors = _errors;
HASH_ITER(hh,myinfo->wallet,wacct,tmp)
{
HASH_ITER(hh,wacct->waddr,waddr,tmp2)
{
wacct->current = waddr;
if ( flag < 0 )
{
memset(&waddr->privkey,0,sizeof(waddr->privkey));
@ -642,6 +641,7 @@ cJSON *iguana_walletiterate(struct supernet_info *myinfo,struct iguana_info *coi
}
else
{
wacct->current = waddr;
if ( (errorflags= iguana_waddrvalidate(myinfo,coin,wacct,waddr,flag,errors)) != 0 )
{
bad++;

2
iguana/m_unix

@ -1,4 +1,4 @@
#./configure --enable-endomorphism --enable-module-ecdh --enable-module-schnorr --enable-module-rangeproof --enable-experimental
#./configure --enable-endomorphism --enable-module-ecdh --enable-module-schnorr --enable-module-rangeproof --enable-experimental --enable-module_recovery
rm ../agents/iguana *.o
git pull
gcc -g -Wno-deprecated -c -O2 -I../../secp256k1-zkp *.c databases/iguana_DB.c

2
iguana/main.c

@ -1149,7 +1149,7 @@ void iguana_appletests(struct supernet_info *myinfo)
exit(-1);
}
sleep(1);*/
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":0,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":1,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":0,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )

2
iguana/tests/sendtoaddress

@ -1,2 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"sendtoaddress\",\"params\":[\"17outUgtsnLkguDuXm14tcQ7dMbdD8KZGK\", 0.001]}"
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"sendtoaddress\",\"params\":[\"RAoMou7euzvDwa9dQwjrNB5A41hrAWgvBt\", 0.0001, \"testcomment\", \"sendcomment\"]}"

2
iguana/tests/signmessageC

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"signmessage\",\"params\":[\"RAoMou7euzvDwa9dQwjrNB5A41hrAWgvBt\", \"testmessage\"]}"

2
iguana/tests/verifymessage

@ -1,2 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"verifymessage\",\"params\":[\"1KHJ4zELwwwND4dytYp7tFyBvELMH1r7a7\", \"MEQCIFLlZ2QVOEq+DzxfmVHy3pXVkCt3SZeNV1byiDVPL42fAiBHL1GN7J7uDW2WULZHruNtOqwfHKJMtL+LndDq08/ybA=\", \"testmessage\"]}"
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"verifymessage\",\"params\":[\"1H5iJUaopB8Zpu1sBTKAPXC2MqVM1DQgRz\", \"IDbLEkZFwjfPfXyEXVKr0x0e3GjiyY3W67/wATCUanqXcD96JlzzDEHfcPjr7YpEEWItqEkR6HC+kvBSFHVp6Jc=\", \"testmessage\"]}"

2
iguana/tests/verifymessageB

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"verifymessage\",\"params\":[\"1KHJ4zELwwwND4dytYp7tFyBvELMH1r7a7\", \"H2dVkWTaunFi4g1W50hsXWQy/m/G0KjrjBujo/SMSxQ3GBFPHRU3F//lTkciFP9c53hBrAnqQGaecsov6Gter3I=\", \"testmessage\"]}"

2
iguana/tests/verifymessageC

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"verifymessage\",\"params\":[\"RAoMou7euzvDwa9dQwjrNB5A41hrAWgvBt\", \"IGIYj77TqR1PnFs4oxY503NpBDJEMA8MB9H+/dF5Xm9xadgIDEDbWor6rbBaUYIxTvGzWDKOQ2z9tHvnPzcn47E=\", \"testmessage\"]}"

8
includes/iguana_apideclares.h

@ -65,20 +65,20 @@ ZERO_ARGS(bitcoinrpc,checkwallet);
ZERO_ARGS(bitcoinrpc,repairwallet);
STRING_ARRAY_OBJ_STRING(bitcoinrpc,signrawtransaction,rawtx,vins,privkeys,sighash);
TWO_STRINGS(bitcoinrpc,signmessage,address,message); //
THREE_STRINGS(bitcoinrpc,verifymessage,address,sig,message); //
TWO_STRINGS(bitcoinrpc,signmessage,address,message);
THREE_STRINGS(bitcoinrpc,verifymessage,address,sig,message);
STRING_AND_INT(bitcoinrpc,sendrawtransaction,rawtx,allowhighfees); //
STRING_ARG(bitcoinrpc,submitblock,rawbytes); //
SS_D_I_SS(bitcoinrpc,sendfrom,fromaccount,toaddress,amount,minconf,comment,comment2); //
S_A_I_S(bitcoinrpc,sendmany,fromaccount,payments,minconf,comment); //
S_D_SS(bitcoinrpc,sendtoaddress,address,amount,comment,comment2); //
INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array); //
ZERO_ARGS(bitcoinrpc,listlockunspent); //
// maybe later
HASH_AND_TWOINTS(bitcoinrpc,listsinceblock,blockhash,target,flag);
ZERO_ARGS(bitcoinrpc,gettxoutsetinfo);
INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array);
ZERO_ARGS(bitcoinrpc,listlockunspent);
ZERO_ARGS(bitcoinrpc,getrawchangeaddress);
SS_D_I_S(bitcoinrpc,move,fromaccount,toaccount,amount,minconf,comment);

Loading…
Cancel
Save