From fe54d0a3825a5b6cd863c79f20dd1e612d7611f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 23 Oct 2017 14:02:59 +0300 Subject: [PATCH 1/3] Test --- iguana/exchanges/LP_nativeDEX.c | 4 ++-- iguana/exchanges/LP_rpc.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 05bef27d5..5467673aa 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -18,13 +18,13 @@ // LP_nativeDEX.c // marketmaker // -// process stats.log local file -> map of realtime activity! -// serialize sighash functions // select oldest utxo first +// process stats.log local file -> map of realtime activity! // handles <-> pubkeys, deal with offline pubkeys, reputations, bonds etc. // // verify portfolio, pricearray, interest to KMD withdraw, reliable networking // dPoW security -> 4: KMD notarized, 5: BTC notarized, after next notary elections +// serialize sighash functions -> otherwise bigendian architectures not supported #include #include "LP_include.h" diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index cec077f1b..02f9d4d03 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -1047,7 +1047,6 @@ int32_t LP_notarization_latest(int32_t *bestheightp,struct iguana_info *coin) blockhash = LP_getbestblockhash(coin); if ( bits256_nonz(blockhash) != 0 ) { - //char str[65]; printf("check %s\n",bits256_str(str,blockhash)); if ( (blockjson= LP_getblock(coin->symbol,blockhash)) != 0 ) { if ( *bestheightp < 0 ) @@ -1055,7 +1054,7 @@ int32_t LP_notarization_latest(int32_t *bestheightp,struct iguana_info *coin) if ( (hasnotarization= LP_hasnotarization(coin,blockjson)) > 0 ) { height = jint(blockjson,"height"); - //printf("height.%d\n",height); + char str[65]; printf("%s height.%d\n",bits256_str(str,blockhash),height); } else { From 77ef39a821358156bb0448b9dff8afed3df95eb4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 23 Oct 2017 14:07:10 +0300 Subject: [PATCH 2/3] Test --- iguana/exchanges/LP_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 02f9d4d03..4f3084b4e 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -1054,7 +1054,7 @@ int32_t LP_notarization_latest(int32_t *bestheightp,struct iguana_info *coin) if ( (hasnotarization= LP_hasnotarization(coin,blockjson)) > 0 ) { height = jint(blockjson,"height"); - char str[65]; printf("%s height.%d\n",bits256_str(str,blockhash),height); + //char str[65]; printf("%s height.%d\n",bits256_str(str,blockhash),height); } else { From ee20bb9efa85f09b15eaacc0b182ce7c8a96202f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 23 Oct 2017 18:33:35 +0300 Subject: [PATCH 3/3] Test --- iguana/exchanges/LP_bitcoin.c | 42 ------------------------------- iguana/exchanges/LP_nativeDEX.c | 4 +-- iguana/exchanges/LP_transaction.c | 41 ++++++++++++++++++++++++++++++ iguana/exchanges/LP_utxos.c | 3 +++ 4 files changed, 46 insertions(+), 44 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 20cc5858f..3874991b7 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -325,33 +325,6 @@ enum opcodetype OP_INVALIDOPCODE = 0xff, }; -bits256 LP_privkeyfind(uint8_t rmd160[20]) -{ - int32_t i; static bits256 zero; - for (i=0; i no privkey\n"); - return(zero); -} - -int32_t LP_privkeyadd(bits256 privkey,uint8_t rmd160[20]) -{ - bits256 tmpkey; - tmpkey = LP_privkeyfind(rmd160); - if ( bits256_nonz(tmpkey) != 0 ) - return(-bits256_cmp(privkey,tmpkey)); - G.LP_privkeys[G.LP_numprivkeys].privkey = privkey; - memcpy(G.LP_privkeys[G.LP_numprivkeys].rmd160,rmd160,20); - //int32_t i; for (i=0; i<20; i++) - // printf("%02x",rmd160[i]); - //char str[65]; printf(" -> add privkey.(%s)\n",bits256_str(str,privkey)); - G.LP_numprivkeys++; - return(G.LP_numprivkeys); -} - int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp) { int32_t i; uint64_t x; @@ -2231,21 +2204,6 @@ int32_t bitcoin_priv2wiflong(uint8_t wiftaddr,char *wifstr,bits256 privkey,uint8 return((int32_t)strlen(wifstr)); } -bits256 LP_privkey(char *coinaddr,uint8_t taddr) -{ - bits256 privkey; uint8_t addrtype,rmd160[20]; - bitcoin_addr2rmd160(taddr,&addrtype,rmd160,coinaddr); - privkey = LP_privkeyfind(rmd160); - return(privkey); -} - -bits256 LP_pubkey(bits256 privkey) -{ - bits256 pubkey; - pubkey = curve25519(privkey,curve25519_basepoint9()); - return(pubkey); -} - char *_setVsigner(uint8_t wiftaddr,uint8_t pubtype,struct vin_info *V,int32_t ind,char *pubstr,char *wifstr) { uint8_t addrtype; diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 5467673aa..bc9f16777 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -18,13 +18,13 @@ // LP_nativeDEX.c // marketmaker // -// select oldest utxo first // process stats.log local file -> map of realtime activity! +// select oldest utxo first // handles <-> pubkeys, deal with offline pubkeys, reputations, bonds etc. // // verify portfolio, pricearray, interest to KMD withdraw, reliable networking // dPoW security -> 4: KMD notarized, 5: BTC notarized, after next notary elections -// serialize sighash functions -> otherwise bigendian architectures not supported +// bigendian architectures need to use little endian for sighash calcs #include #include "LP_include.h" diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 8ecad59c7..b72cb111a 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -18,6 +18,47 @@ // LP_transaction.c // marketmaker // +bits256 LP_privkeyfind(uint8_t rmd160[20]) +{ + int32_t i; static bits256 zero; + for (i=0; i no privkey\n"); + return(zero); +} + +int32_t LP_privkeyadd(bits256 privkey,uint8_t rmd160[20]) +{ + bits256 tmpkey; + tmpkey = LP_privkeyfind(rmd160); + if ( bits256_nonz(tmpkey) != 0 ) + return(-bits256_cmp(privkey,tmpkey)); + G.LP_privkeys[G.LP_numprivkeys].privkey = privkey; + memcpy(G.LP_privkeys[G.LP_numprivkeys].rmd160,rmd160,20); + //int32_t i; for (i=0; i<20; i++) + // printf("%02x",rmd160[i]); + //char str[65]; printf(" -> add privkey.(%s)\n",bits256_str(str,privkey)); + G.LP_numprivkeys++; + return(G.LP_numprivkeys); +} + +bits256 LP_privkey(char *coinaddr,uint8_t taddr) +{ + bits256 privkey; uint8_t addrtype,rmd160[20]; + bitcoin_addr2rmd160(taddr,&addrtype,rmd160,coinaddr); + privkey = LP_privkeyfind(rmd160); + return(privkey); +} + +bits256 LP_pubkey(bits256 privkey) +{ + bits256 pubkey; + pubkey = curve25519(privkey,curve25519_basepoint9()); + return(pubkey); +} int32_t LP_gettx_presence(char *symbol,bits256 expectedtxid) { diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 565cfdda2..54b5aec3a 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -18,6 +18,9 @@ // marketmaker // + + + int32_t LP_ismine(struct LP_utxoinfo *utxo) { if ( utxo != 0 && bits256_cmp(utxo->pubkey,G.LP_mypub25519) == 0 )