Browse Source

Merge pull request #666 from jl777/jl777

external elected file for notarizations
patch-3
jl777 7 years ago
committed by GitHub
parent
commit
82986ef420
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      iguana/dPoW.h
  2. 34
      iguana/dpow/dpow_network.c
  3. 139
      iguana/dpow/dpow_rpc.c
  4. 1
      iguana/elected
  5. 15
      iguana/exchanges/LP_commands.c
  6. 7
      iguana/exchanges/LP_network.c
  7. 2
      iguana/exchanges/LP_ordermatch.c
  8. 12
      iguana/exchanges/LP_utxo.c
  9. 18
      iguana/iguana_notary.c
  10. 12
      iguana/main.c

2
iguana/dPoW.h

@ -47,7 +47,7 @@
#define DPOW_MAXSIGLEN 128
#define DEX_VERSION 0x0105
#define DPOW_SOCK 7775
#define DPOW_SOCKPORT 7775
#define DEX_SOCK 7774
#define PUB_SOCK 7773
#define REP_SOCK 7772

34
iguana/dpow/dpow_network.c

@ -13,6 +13,10 @@
* *
******************************************************************************/
extern uint16_t Notaries_port;
extern int32_t Notaries_numseeds;
extern char *Notaries_seeds[];
struct signed_nnpacket
{
uint8_t sig64[64];
@ -24,14 +28,14 @@ struct signed_nnpacket
void dex_init(struct supernet_info *myinfo)
{
int32_t i,j,mask = 0; char *seeds[] = { "78.47.196.146", "5.9.102.210", "149.56.29.163", "191.235.80.138", "88.198.65.74", "94.102.63.226", "129.232.225.202", "104.255.64.3", "52.72.135.200", "149.56.28.84", "103.18.58.150", "221.121.144.140", "123.249.79.12", "103.18.58.146", "27.50.93.252", "176.9.0.233", "94.102.63.227", "167.114.227.223", "27.50.68.219", "192.99.233.217", "94.102.63.217", "45.64.168.216" };
int32_t i,j,mask = 0;
OS_randombytes((void *)&i,sizeof(i));
srand(i);
for (i=0; i<sizeof(myinfo->dexseed_ipaddrs)/sizeof(*myinfo->dexseed_ipaddrs); i++)
{
while ( 1 )
{
j = (rand() % (sizeof(seeds)/sizeof(*seeds)));
j = (rand() % Notaries_numseeds);
if ( i < 2 )
j = i;
if ( ((1 << j) & mask) == 0 )
@ -41,8 +45,8 @@ void dex_init(struct supernet_info *myinfo)
#ifdef NOTARY_TESTMODE
seeds[j] = NOTARY_TESTMODE;
#endif
printf("seed.[%d] <- %s\n",i,seeds[j]);
strcpy(myinfo->dexseed_ipaddrs[i],seeds[j]);
printf("seed.[%d] <- %s\n",i,Notaries_seeds[j]);
strcpy(myinfo->dexseed_ipaddrs[i],Notaries_seeds[j]);
myinfo->dexipbits[i] = (uint32_t)calc_ipbits(myinfo->dexseed_ipaddrs[i]);
}
myinfo->numdexipbits = i;
@ -1002,8 +1006,8 @@ char *_dex_getnotaries(struct supernet_info *myinfo,char *symbol)
}
else
{
extern const char *Notaries_elected[][2];
myinfo->numnotaries = 64;//sizeof(Notaries_elected)/sizeof(*Notaries_elected);
extern char *Notaries_elected[][2]; extern int32_t Notaries_num;
myinfo->numnotaries = Notaries_num;//sizeof(Notaries_elected)/sizeof(*Notaries_elected);
for (i=0; i<myinfo->numnotaries; i++)
{
decode_hex(myinfo->notaries[i],33,(char *)Notaries_elected[i][1]);
@ -1292,7 +1296,7 @@ int32_t dpow_addnotary(struct supernet_info *myinfo,struct dpow_info *dp,char *i
if ( myinfo->IAMNOTARY == 0 )
return(-1);
portable_mutex_lock(&myinfo->notarymutex);
if ( myinfo->dpowsock >= 0 && myinfo->dexsock >= 0 )
if ( myinfo->dpowsock >= 0 )//&& myinfo->dexsock >= 0 )
{
ipbits = (uint32_t)calc_ipbits(ipaddr);
for (iter=0; iter<2; iter++)
@ -1315,9 +1319,9 @@ int32_t dpow_addnotary(struct supernet_info *myinfo,struct dpow_info *dp,char *i
ptr[n] = ipbits;
if ( iter == 0 && strcmp(ipaddr,myinfo->ipaddr) != 0 )
{
retval = nn_connect(myinfo->dpowsock,nanomsg_tcpname(0,str,ipaddr,DPOW_SOCK));
retval = nn_connect(myinfo->dpowsock,nanomsg_tcpname(0,str,ipaddr,Notaries_port));
printf("NN_CONNECT to (%s)\n",str);
retval = nn_connect(myinfo->dexsock,nanomsg_tcpname(0,str,ipaddr,DEX_SOCK));
//retval = nn_connect(myinfo->dexsock,nanomsg_tcpname(0,str,ipaddr,DEX_SOCK));
}
n++;
qsort(ptr,n,sizeof(uint32_t),_increasing_ipbits);
@ -1353,13 +1357,13 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
pubsock = myinfo->pubsock;
if ( dpowsock < 0 && (dpowsock= nn_socket(AF_SP,NN_BUS)) >= 0 )
{
if ( nn_bind(dpowsock,nanomsg_tcpname(myinfo,str,myinfo->ipaddr,DPOW_SOCK)) < 0 )
if ( nn_bind(dpowsock,nanomsg_tcpname(myinfo,str,myinfo->ipaddr,Notaries_port)) < 0 )
{
printf("error binding to dpowsock (%s)\n",nanomsg_tcpname(myinfo,str,myinfo->ipaddr,DPOW_SOCK));
printf("error binding to dpowsock (%s)\n",nanomsg_tcpname(myinfo,str,myinfo->ipaddr,Notaries_port));
nn_close(dpowsock);
dpowsock = -1;
}
else
else if ( 0 )
{
printf("NN_BIND to %s\n",str);
if ( dexsock < 0 && (dexsock= nn_socket(AF_SP,NN_BUS)) >= 0 )
@ -2019,7 +2023,7 @@ void dpow_ipbitsadd(struct supernet_info *myinfo,struct dpow_info *dp,uint32_t *
dpow_addnotary(myinfo,dp,ipaddr);
}
} else if ( missing > 0 )
printf("IGNORE from.%d RECV numips.%d numipbits.%d matched.%d missing.%d\n",fromid,numipbits,n,matched,missing);
printf("IGNORE from.%d RECV numips.%d numipbits.%d matched.%d missing.%d maxipbits.%d\n",fromid,numipbits,n,matched,missing,maxipbits);
expand_ipbits(ipaddr,senderipbits);
dpow_addnotary(myinfo,dp,ipaddr);
expand_ipbits(ipaddr,myinfo->myaddr.myipbits);
@ -2093,7 +2097,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} else flags |= 1;
if ( freeptr != 0 )
nn_freemsg(freeptr), np = 0, freeptr = 0;
if ( myinfo->dexsock >= 0 ) // from servers
if ( 0 && myinfo->dexsock >= 0 ) // from servers
{
freeptr = 0;
if ( (flags & 2) == 0 && (size= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 )
@ -2111,7 +2115,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
if ( freeptr != 0 )
nn_freemsg(freeptr), dexp = 0, freeptr = 0;
}
if ( myinfo->repsock >= 0 ) // from clients
if ( 0 && myinfo->repsock >= 0 ) // from clients
{
dexp = 0;
if ( (flags & 4) == 0 && (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 )

139
iguana/dpow/dpow_rpc.c

@ -49,78 +49,79 @@ cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
}
return(json);
}
const char *Notaries_elected[][2] =
char *Notaries_elected[64][2];
char *seeds[] = { "78.47.196.146", "5.9.102.210", "149.56.29.163", "191.235.80.138", "88.198.65.74", "94.102.63.226", "129.232.225.202", "104.255.64.3", "52.72.135.200", "149.56.28.84", "103.18.58.150", "221.121.144.140", "123.249.79.12", "103.18.58.146", "27.50.93.252", "176.9.0.233", "94.102.63.227", "167.114.227.223", "27.50.68.219", "192.99.233.217", "94.102.63.217", "45.64.168.216" };
int32_t Notaries_numseeds = (int32_t)(sizeof(seeds)/sizeof(*seeds)),Notaries_num,Notaries_BTCminsigs = DPOW_MINSIGS,Notaries_minsigs = DPOW_MIN_ASSETCHAIN_SIGS;
uint16_t Notaries_port = DPOW_SOCKPORT;
char *Notaries_seeds[64];
int32_t komodo_initjson(char *fname)
{
{ "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
{ "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" },
{ "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" },
{ "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" },
{ "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" },
{ "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" },
{ "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" },
{ "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" },
{ "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" },
{ "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" },
{ "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10
{ "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" },
{ "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" },
{ "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" },
{ "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" },
{ "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" },
{ "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" },
{ "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" },
{ "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" },
{ "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" },
{ "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20
{ "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" },
{ "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" },
{ "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" },
{ "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" },
{ "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" },
{ "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" },
{ "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" },
{ "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" },
{ "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" },
{ "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30
{ "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" },
{ "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" },
{ "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" },
{ "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" },
{ "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" },
{ "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" },
{ "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" },
{ "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" },
{ "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" },
{ "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40
{ "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" },
{ "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" },
{ "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" },
{ "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" },
{ "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" },
{ "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" },
{ "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" },
{ "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" },
{ "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" },
{ "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50
{ "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" },
{ "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" },
{ "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" },
{ "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" },
{ "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" },
{ "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" },
{ "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" },
{ "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" },
{ "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" },
{ "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60
{ "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" },
{ "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" },
{ "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" }
};
char *fstr,*field,*hexstr; cJSON *argjson,*array,*item; long fsize; uint16_t port; int32_t i,n,num,retval = -1;
for (i=0; i<Notaries_numseeds; i++)
Notaries_seeds[i] = seeds[i];
if ( (fstr= OS_filestr(&fsize,fname)) != 0 )
{
if ( (argjson= cJSON_Parse(fstr)) != 0 )
{
if ( (port= juint(argjson,"port")) != 0 )
Notaries_port = port;
if ( (num= juint(argjson,"BTCminsigs")) > Notaries_BTCminsigs )
Notaries_BTCminsigs = num;
if ( (num= juint(argjson,"minsigs")) > Notaries_minsigs )
Notaries_minsigs = num;
if ( (array= jarray(&n,argjson,"seeds")) != 0 && n <= 64 )
{
for (i=0; i<n; i++)
{
Notaries_seeds[i] = clonestr(jstri(array,i));
printf("%s ",Notaries_seeds[i]);
}
printf("Notaries_numseeds.%d\n",Notaries_numseeds);
}
if ( (array= jarray(&n,argjson,"notaries")) != 0 && n <= 64 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
field = jfieldname(item);
if ( (hexstr= jstr(item,field)) != 0 && is_hexstr(hexstr,0) == 66 )
{
Notaries_elected[i][0] = clonestr(field);
Notaries_elected[i][1] = clonestr(hexstr);
//printf("%d of %d: %s %s\n",i,n,field,hexstr);
}
else
{
printf("couldnt find (%s) in %s or non-hex (%s)\n",field,jprint(item,0),hexstr!=0?hexstr:"");
break;
}
}
if ( i == n )
{
Notaries_num = n;
retval = 0;
printf("numnotaries %d, port.%d minsigs.%d BTCminsigs.%d\n",Notaries_num,Notaries_port,Notaries_BTCminsigs,Notaries_minsigs);
}
}
free_json(argjson);
}
free(fstr);
}
return(retval);
}
int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height)
{
int32_t i,num=-1; struct iguana_info *coin; char params[256],*retstr,*pubkeystr; cJSON *retjson,*item,*array;
if ( (coin= iguana_coinfind(symbol)) != 0 )
int32_t i; //,num=-1; struct iguana_info *coin; char params[256],*retstr,*pubkeystr; cJSON *retjson,*item,*array;
if ( Notaries_num > 0 )
{
for (i=0; i<Notaries_num; i++)
decode_hex(pubkeys[i],33,Notaries_elected[i][1]);
return(Notaries_num);
} else return(-1);
/*if ( (coin= iguana_coinfind(symbol)) != 0 )
{
if ( height < 0 )
{
@ -168,7 +169,7 @@ int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height)
}
}
//printf("komodo_notaries returns.%d\n",num);
return(num);
return(num);*/
}
bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin)

1
iguana/elected

File diff suppressed because one or more lines are too long

15
iguana/exchanges/LP_commands.c

@ -167,7 +167,7 @@ instantdex_claim()\n\
timelock(coin, duration, destaddr=(tradeaddr), amount)\n\
unlockedspend(coin, txid)\n\
opreturndecrypt(coin, txid, passphrase)\n\
getendpoint()\n\
getendpoint(port=5555)\n\
jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
\"}"));
//sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\
@ -234,22 +234,25 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
}
else if ( strcmp(method,"getendpoint") == 0 )
{
int32_t err,mode;
int32_t err,mode; uint16_t wsport = 5555; char endpoint[64],bindpoint[64];
if ( juint(argjson,"port") != 0 )
wsport = juint(argjson,"port");
retjson = cJSON_CreateObject();
if ( IPC_ENDPOINT >= 0 )
{
jaddstr(retjson,"error","IPC endpoint already exists");
jaddstr(retjson,"endpoint","ws://*:5555");
jaddnum(retjson,"socket",IPC_ENDPOINT);
}
else
{
if ( (IPC_ENDPOINT= nn_socket(AF_SP,NN_PAIR)) >= 0 )
{
if ( (err= nn_bind(IPC_ENDPOINT,"ws://*:5555")) >= 0 )
sprintf(bindpoint,"ws://*:%u",port);
sprintf(endpoint,"ws://127.0.0.1:%u",port);
if ( (err= nn_bind(IPC_ENDPOINT,bindpoint)) >= 0 )
{
jaddstr(retjson,"result","success");
jaddstr(retjson,"endpoint","ws://127.0.0.1:5555");
jaddstr(retjson,"endpoint",endpoint);
jaddnum(retjson,"socket",IPC_ENDPOINT);
mode = NN_WS_MSG_TYPE_TEXT;
err = nn_setsockopt(IPC_ENDPOINT,NN_SOL_SOCKET,NN_WS_MSG_TYPE,&mode,sizeof(mode));
@ -601,6 +604,8 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
{
if ( jobj(argjson,"outputs") == 0 && jstr(argjson,"opreturn") == 0 )
return(clonestr("{\"error\":\"withdraw needs to have outputs\"}"));
else if ( ptr->etomic[0] != 0 )
return(clonestr("{\"error\":\"use eth_withdraw for ETH/ERC20\"}"));
else return(LP_withdraw(ptr,argjson));
}
return(clonestr("{\"error\":\"cant find coind\"}"));

7
iguana/exchanges/LP_network.c

@ -433,7 +433,7 @@ struct LP_queuedcommand
void LP_commandQ_loop(void *ctx)
{
struct LP_queuedcommand *ptr,*tmp; int32_t size,nonz; char *retstr; cJSON *argjson,*retjson,*result;
struct LP_queuedcommand *ptr,*tmp; int32_t len,size,nonz; char *retstr; cJSON *argjson,*retjson,*result;
while ( LP_STOP_RECEIVED == 0 )
{
nonz = 0;
@ -478,7 +478,10 @@ void LP_commandQ_loop(void *ctx)
retstr = jprint(retjson,1);
//printf("send (%s)\n",retstr);
}
if ( (size= nn_send(ptr->responsesock,retstr,(int32_t)strlen(retstr)+1,0)) <= 0 )
len = (int32_t)strlen(retstr);
if ( ptr->queueid == 0 )
len++;
if ( (size= nn_send(ptr->responsesock,retstr,len,0)) <= 0 )
printf("error sending result\n");
}
if ( retstr != 0 )

2
iguana/exchanges/LP_ordermatch.c

@ -1491,7 +1491,9 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel
memset(&A,0,sizeof(A));
LP_address_utxo_reset(relcoin);
if ( (autxo= LP_address_myutxopair(&A,0,utxos,max,relcoin,relcoin->smartaddr,txfee,dstr(destsatoshis),maxprice,desttxfee)) == 0 )
{
return(clonestr("{\"error\":\"cant find a deposit that is close enough in size. make another deposit that is just a bit larger than what you want to trade\"}"));
}
//printf("bestfit selected alice (%.8f %.8f) for %.8f sats %.8f\n",dstr(autxo->payment.value),dstr(autxo->fee.value),dstr(destsatoshis),dstr(autxo->swap_satoshis));
if ( destsatoshis - desttxfee < autxo->swap_satoshis )
{

12
iguana/exchanges/LP_utxo.c

@ -471,7 +471,7 @@ int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,str
struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
{
struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,m,vout,height; cJSON *array,*item,*txobj; bits256 zero; int64_t value; bits256 txid; uint32_t now;
struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,numconfs,m,vout,height; cJSON *array,*item,*txobj; bits256 zero; int64_t value; bits256 txid; uint32_t now;
LP_address(coin,coin->smartaddr);
memset(zero.bytes,0,sizeof(zero));
LP_listunspent_issue(coin->symbol,coin->smartaddr,2,zero,zero);
@ -511,10 +511,16 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
if ( 1 )
{
if ( (txobj= LP_gettxout(coin->symbol,coin->smartaddr,txid,vout)) == 0 )
{
//printf("skip null gettxout %s.v%d\n",bits256_str(str,txid),vout);
continue;
}
else free_json(txobj);
if ( LP_numconfirms(coin->symbol,coin->smartaddr,txid,vout,0) <= 0 )
if ( (numconfs= LP_numconfirms(coin->symbol,coin->smartaddr,txid,vout,0)) <= 0 )
{
//printf("skip numconfs.%d %s.v%d\n",numconfs,bits256_str(str,txid),vout);
continue;
}
}
LP_address_utxoadd(1,now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1);
if ( (up= LP_address_utxofind(coin,coin->smartaddr,txid,vout)) == 0 )
@ -525,7 +531,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
//printf("%.8f ",dstr(value));
}
}
printf("added %d from %s listunspents\n",m,coin->symbol);
printf("added %d of %d from %s listunspents\n",m,n,coin->symbol);
}
free_json(array);
}

18
iguana/iguana_notary.c

@ -86,7 +86,7 @@ int32_t dpow_txhasnotarization(struct supernet_info *myinfo,struct iguana_info *
decode_hex(script,len,hexstr);
if ( script[0] == 33 && script[34] == 0xac )
{
for (j=0; j<sizeof(Notaries_elected)/sizeof(*Notaries_elected); j++)
for (j=0; j<Notaries_num; j++)
{
if ( strncmp(Notaries_elected[j][1],hexstr+2,66) == 0 )
{
@ -141,11 +141,11 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
if ( strcmp("BTC",dp->dest) == 0 )
{
freq = DPOW_CHECKPOINTFREQ;
minsigs = DPOW_MINSIGS;
minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
}
else
{
minsigs = DPOW_MIN_ASSETCHAIN_SIGS;
minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS;
if ( strcmp("CHIPS",dp->symbol) == 0 )
freq = 100;
else freq = 1;
@ -197,9 +197,9 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
ptrs[0] = (void *)myinfo;
ptrs[1] = (void *)dp;
ptrs[2] = (void *)(uint64_t)minsigs;
if ( strcmp(dp->dest,"KMD") == 0 )
ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains
else ptrs[3] = (void *)DPOW_DURATION;
if ( strcmp(dp->dest,"KMD") != 0 )
ptrs[3] = (void *)DPOW_DURATION;
else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains
ptrs[4] = 0;
memcpy(&ptrs[5],&checkpoint,sizeof(checkpoint));
dp->activehash = checkpoint.blockhash.hash;
@ -347,9 +347,9 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
void dpow_addresses()
{
int32_t i; char coinaddr[64]; uint8_t pubkey[33];
for (i=0; i<sizeof(Notaries)/sizeof(*Notaries); i++)
for (i=0; i<Notaries_num; i++)
{
decode_hex(pubkey,33,Notaries[i][1]);
decode_hex(pubkey,33,Notaries_elected[i][1]);
bitcoin_address(coinaddr,60,pubkey,33);
printf("%s ",coinaddr);
}
@ -626,7 +626,7 @@ void _iguana_notarystats(char *fname,int32_t totals[64],int32_t dispflag)
if ( dispflag != 0 )
{
printf("after %s\n",fname);
for (i=0; i<64; i++)
for (i=0; i<Notaries_num; i++)
{
if ( totals[i] != 0 )
printf("%s, %d\n",Notaries_elected[i][0],totals[i]);

12
iguana/main.c

@ -2157,9 +2157,11 @@ void komodo_REVS_merge(char *str,char *str2)
getchar();
}
int32_t komodo_initjson(char *fname);
void iguana_main(void *arg)
{
int32_t usessl = 0,ismainnet = 1, do_OStests = 0; struct supernet_info *myinfo;
int32_t usessl = 0,ismainnet = 1, do_OStests = 0; struct supernet_info *myinfo; char *elected = "elected";
if ( (IGUANA_BIGENDIAN= iguana_isbigendian()) > 0 )
printf("BIGENDIAN\n");
else if ( IGUANA_BIGENDIAN == 0 )
@ -2192,7 +2194,6 @@ void iguana_main(void *arg)
iguana_Qinit();
libgfshare_init(myinfo,myinfo->logs,myinfo->exps);
myinfo->dpowsock = myinfo->dexsock = myinfo->pubsock = myinfo->subsock = myinfo->reqsock = myinfo->repsock = -1;
dex_init(myinfo);
myinfo->psockport = 30000;
if ( arg != 0 )
{
@ -2217,7 +2218,14 @@ void iguana_main(void *arg)
myinfo->rpcport = atoi(&((char *)arg)[6]);
printf("OVERRIDE IGUANA port <- %u\n",myinfo->rpcport);
}
else elected = (char *)arg;
}
if ( komodo_initjson(elected) < 0 )
{
printf("didnt find any elected notaries JSON in (%s)\n",elected);
exit(-1);
}
dex_init(myinfo);
#ifdef IGUANA_OSTESTS
do_OStests = 1;
#endif

Loading…
Cancel
Save