jl777 7 years ago
parent
commit
ee20bb9efa
  1. 42
      iguana/exchanges/LP_bitcoin.c
  2. 4
      iguana/exchanges/LP_nativeDEX.c
  3. 41
      iguana/exchanges/LP_transaction.c
  4. 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;

4
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 <stdio.h>
#include "LP_include.h"

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