Browse Source

Merge pull request #394 from jl777/spvdex

Spvdex
etomic
jl777 7 years ago
committed by GitHub
parent
commit
7168453d98
  1. 42
      iguana/exchanges/LP_bitcoin.c
  2. 2
      iguana/exchanges/LP_nativeDEX.c
  3. 3
      iguana/exchanges/LP_rpc.c
  4. 41
      iguana/exchanges/LP_transaction.c
  5. 3
      iguana/exchanges/LP_utxos.c

42
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<G.LP_numprivkeys; i++)
if ( memcmp(rmd160,G.LP_privkeys[i].rmd160,20) == 0 )
return(G.LP_privkeys[i].privkey);
//for (i=0; i<20; i++)
// printf("%02x",rmd160[i]);
//printf(" -> 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;

2
iguana/exchanges/LP_nativeDEX.c

@ -19,12 +19,12 @@
// marketmaker
//
// process stats.log local file -> map of realtime activity!
// serialize sighash functions
// 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
// bigendian architectures need to use little endian for sighash calcs
#include <stdio.h>
#include "LP_include.h"

3
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
{

41
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<G.LP_numprivkeys; i++)
if ( memcmp(rmd160,G.LP_privkeys[i].rmd160,20) == 0 )
return(G.LP_privkeys[i].privkey);
//for (i=0; i<20; i++)
// printf("%02x",rmd160[i]);
//printf(" -> 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)
{

3
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 )

Loading…
Cancel
Save