jl777
9 years ago
32 changed files with 1405 additions and 455 deletions
@ -0,0 +1,421 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
#include "../iguana/iguana777.h" |
||||
|
|
||||
|
char *basilisk_finish(struct basilisk_item *ptr,cJSON **argjsonp,int32_t besti) |
||||
|
{ |
||||
|
int32_t i; char *retstr = 0; |
||||
|
for (i=0; i<ptr->numresults; i++) |
||||
|
{ |
||||
|
if ( besti >= 0 && i != besti ) |
||||
|
{ |
||||
|
if ( ptr->results[i] != 0 ) |
||||
|
free(ptr->results[i]); |
||||
|
if ( ptr->resultargs[i] != 0 ) |
||||
|
free_json(ptr->resultargs[i]); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
retstr = ptr->results[i]; |
||||
|
if ( argjsonp != 0 ) |
||||
|
*argjsonp = ptr->resultargs[i]; |
||||
|
} |
||||
|
ptr->results[i] = 0; |
||||
|
ptr->resultargs[i] = 0; |
||||
|
} |
||||
|
ptr->finished = (uint32_t)time(NULL); |
||||
|
return(retstr); |
||||
|
} |
||||
|
|
||||
|
#include "basilisk_bitcoin.c" |
||||
|
#include "basilisk_nxt.c" |
||||
|
#include "basilisk_ether.c" |
||||
|
#include "basilisk_waves.c" |
||||
|
#include "basilisk_lisk.c" |
||||
|
|
||||
|
cJSON *basilisk_json(struct supernet_info *myinfo,cJSON *hexjson,uint32_t basilisktag,int32_t timeout) |
||||
|
{ |
||||
|
char *str,*buf; cJSON *retjson; |
||||
|
jaddnum(hexjson,"basilisktag",basilisktag); |
||||
|
str = jprint(hexjson,0); |
||||
|
buf = malloc(strlen(str)*2 + 1); |
||||
|
init_hexbytes_noT(buf,(uint8_t *)str,(int32_t)strlen(str)); |
||||
|
free(str); |
||||
|
retjson = cJSON_CreateObject(); |
||||
|
jaddstr(retjson,"hexmsg",buf); |
||||
|
free(buf); |
||||
|
jaddstr(retjson,"agent","SuperNET"); |
||||
|
jaddstr(retjson,"method","DHT"); |
||||
|
jaddnum(retjson,"request",1); |
||||
|
jaddnum(retjson,"plaintext",1); |
||||
|
jaddbits256(retjson,"categoryhash",myinfo->basilisk_category); |
||||
|
jaddnum(retjson,"timeout",timeout); |
||||
|
return(retjson); |
||||
|
} |
||||
|
|
||||
|
int32_t basilisk_submit(struct supernet_info *myinfo,cJSON *reqjson,int32_t timeout,int32_t fanout,struct basilisk_item *ptr) |
||||
|
{ |
||||
|
int32_t i,j,k,l,r2,r,n; struct iguana_peer *addr; struct iguana_info *coin; char *reqstr; cJSON *tmpjson; |
||||
|
tmpjson = basilisk_json(myinfo,reqjson,ptr->basilisktag,timeout); |
||||
|
reqstr = jprint(tmpjson,1); |
||||
|
if ( fanout <= 0 ) |
||||
|
fanout = BASILISK_MINFANOUT; |
||||
|
else if ( fanout > BASILISK_MAXFANOUT ) |
||||
|
fanout = BASILISK_MAXFANOUT; |
||||
|
r2 = rand(); |
||||
|
for (l=n=0; l<IGUANA_MAXCOINS; l++) |
||||
|
{ |
||||
|
i = (l + r2) % IGUANA_MAXCOINS; |
||||
|
if ( (coin= Coins[i]) != 0 ) |
||||
|
{ |
||||
|
r = rand(); |
||||
|
for (k=0; k<IGUANA_MAXPEERS; k++) |
||||
|
{ |
||||
|
j = (k + r) % IGUANA_MAXPEERS; |
||||
|
if ( (addr= &coin->peers.active[j]) != 0 && addr->supernet != 0 && addr->usock >= 0 ) |
||||
|
{ |
||||
|
ptr->submit = (uint32_t)time(NULL); |
||||
|
iguana_send_supernet(addr,reqstr,0); |
||||
|
if ( n++ > fanout ) |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
free(reqstr); |
||||
|
return(n); |
||||
|
} |
||||
|
|
||||
|
struct basilisk_item *basilisk_issue(struct supernet_info *myinfo,cJSON *hexjson,int32_t timeoutmillis,int32_t fanout,int32_t minresults,uint32_t basilisktag) |
||||
|
{ |
||||
|
double expiration; struct basilisk_item *ptr; |
||||
|
ptr = calloc(1,sizeof(*ptr)); |
||||
|
if ( basilisktag == 0 ) |
||||
|
basilisktag = rand(); |
||||
|
ptr->basilisktag = basilisktag; |
||||
|
queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); |
||||
|
if ( basilisk_submit(myinfo,hexjson,timeoutmillis,fanout,ptr) > 0 ) |
||||
|
{ |
||||
|
if ( timeoutmillis >= 0 ) |
||||
|
{ |
||||
|
expiration = OS_milliseconds() + ((timeoutmillis == 0) ? BASILISK_TIMEOUT : timeoutmillis); |
||||
|
while ( OS_milliseconds() < expiration && ptr->finished == 0 && ptr->numresults < minresults ) |
||||
|
usleep(timeoutmillis/100 + 1); |
||||
|
} |
||||
|
} |
||||
|
return(ptr); |
||||
|
} |
||||
|
|
||||
|
void basilisk_functions(struct iguana_info *coin) |
||||
|
{ |
||||
|
switch ( coin->protocol ) |
||||
|
{ |
||||
|
case IGUANA_PROTOCOL_BITCOIN: |
||||
|
coin->basilisk_balances = basilisk_bitcoinbalances; |
||||
|
coin->basilisk_rawtx = basilisk_bitcoinrawtx; |
||||
|
coin->basilisk_value = basilisk_bitcoinvalue; |
||||
|
break; |
||||
|
/*case IGUANA_PROTOCOL_IOTA:
|
||||
|
coin->basilisk_balances = basilisk_iotabalances; |
||||
|
coin->basilisk_rawtx = basilisk_iotarawtx; |
||||
|
break; |
||||
|
case IGUANA_PROTOCOL_NXT: |
||||
|
coin->basilisk_balances = basilisk_nxtbalances; |
||||
|
coin->basilisk_rawtx = basilisk_nxtrawtx; |
||||
|
break; |
||||
|
case IGUANA_PROTOCOL_ETHER: |
||||
|
coin->basilisk_balances = basilisk_etherbalances; |
||||
|
coin->basilisk_rawtx = basilisk_etherrawtx; |
||||
|
break; |
||||
|
case IGUANA_PROTOCOL_WAVES: |
||||
|
coin->basilisk_balances = basilisk_wavesbalances; |
||||
|
coin->basilisk_rawtx = basilisk_wavesrawtx; |
||||
|
break; |
||||
|
case IGUANA_PROTOCOL_LISK: |
||||
|
coin->basilisk_balances = basilisk_liskbalances; |
||||
|
coin->basilisk_rawtx = basilisk_liskrawtx; |
||||
|
break;*/ |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
char *basilisk_issuerawtx(struct supernet_info *myinfo,char *remoteaddr,uint32_t basilisktag,char *symbol,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *spendscriptstr,char *changeaddr,int64_t txfee,int32_t minconf,cJSON *addresses,int32_t timeout) |
||||
|
{ |
||||
|
struct iguana_info *coin; char *rawtx=0; |
||||
|
*vinsp = 0; |
||||
|
if ( (coin= iguana_coinfind(symbol)) != 0 ) |
||||
|
{ |
||||
|
if ( coin->basilisk_rawtx != 0 ) |
||||
|
rawtx = (*coin->basilisk_rawtx)(myinfo,coin,remoteaddr,basilisktag,vinsp,locktime,satoshis,changeaddr,txfee,addresses,minconf,spendscriptstr,timeout); |
||||
|
} |
||||
|
return(rawtx); |
||||
|
} |
||||
|
|
||||
|
int64_t basilisk_issuebalances(struct supernet_info *myinfo,char *remoteaddr,int32_t basilisktag,char *symbol,cJSON **argsp,int32_t lastheight,int32_t minconf,cJSON *addresses,int32_t timeout) |
||||
|
{ |
||||
|
struct iguana_info *coin; int64_t balance = 0; |
||||
|
*argsp = 0; |
||||
|
if ( (coin= iguana_coinfind(symbol)) != 0 ) |
||||
|
{ |
||||
|
if ( coin->basilisk_balances != 0 ) |
||||
|
balance = (*coin->basilisk_balances)(myinfo,coin,remoteaddr,basilisktag,argsp,lastheight,minconf,addresses,timeout); |
||||
|
} |
||||
|
return(balance); |
||||
|
} |
||||
|
|
||||
|
int64_t basilisk_issuevalue(struct supernet_info *myinfo,char *remoteaddr,int32_t basilisktag,char *symbol,cJSON **argsp,bits256 txid,int16_t vout,char *coinaddr,int32_t timeout) |
||||
|
{ |
||||
|
struct iguana_info *coin; int64_t value = 0; |
||||
|
*argsp = 0; |
||||
|
if ( (coin= iguana_coinfind(symbol)) != 0 ) |
||||
|
{ |
||||
|
if ( coin->basilisk_value != 0 ) |
||||
|
value = (*coin->basilisk_value)(myinfo,coin,remoteaddr,basilisktag,txid,vout,coinaddr,timeout); |
||||
|
} |
||||
|
return(value); |
||||
|
} |
||||
|
|
||||
|
#include "../includes/iguana_apidefs.h" |
||||
|
#include "../includes/iguana_apideclares.h" |
||||
|
|
||||
|
INT_ARRAY_STRING(basilisk,balances,lastheight,addresses,activecoin) |
||||
|
{ |
||||
|
/*uint64_t amount,total = 0; cJSON *item,*result,*array,*retjson,*hexjson; int32_t i,n,minconf=0; char *retstr,*balancestr,*coinaddr;
|
||||
|
retjson = cJSON_CreateObject(); |
||||
|
if ( activecoin != 0 && activecoin[0] != 0 && (coin= iguana_coinfind(activecoin)) != 0 ) |
||||
|
{ |
||||
|
xxx |
||||
|
jadd(retjson,"balances",array); |
||||
|
jaddnum(retjson,"total",dstr(total)); |
||||
|
if ( lastheight != 0 ) |
||||
|
jaddnum(retjson,"lastheight",lastheight); |
||||
|
if ( remoteaddr != 0 && remoteaddr[0] != 0 && strcmp(remoteaddr,"127.0.0.1") != 0 ) |
||||
|
{ |
||||
|
//printf("remote req.(%s)\n",jprint(retjson,0));
|
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddstr(hexjson,"rawtx",jprint(retjson,1)); |
||||
|
jaddstr(hexjson,"agent","iguana"); |
||||
|
jaddstr(hexjson,"method","rawtx_result"); |
||||
|
jaddstr(hexjson,"activecoin",activecoin); |
||||
|
jaddnum(hexjson,"basilisktag",lastheight); |
||||
|
retjson = iguana_json(myinfo,hexjson); |
||||
|
} else jaddstr(retjson,"result","success"); |
||||
|
return(jprint(retjson,1)); |
||||
|
} |
||||
|
else if ( remoteaddr == 0 || remoteaddr[0] == 0 || strcmp(remoteaddr,"127.0.0.1") == 0 ) |
||||
|
{ |
||||
|
if ( (retstr= basilisk_request_andwait(myinfo,&myinfo->basiliskQ,0,json,lastheight,juint(json,"timeout"))) == 0 ) |
||||
|
return(clonestr("{\"error\":\"timeout waiting for remote request\"}")); |
||||
|
else return(retstr); |
||||
|
} else return(clonestr("{\"error\":\"invalid remoterequest when not relaynode\"}")); |
||||
|
} else */return(clonestr("{\"error\":\"invalid request for inactive coin\"}")); |
||||
|
} |
||||
|
|
||||
|
STRING_ARRAY_OBJ_STRING(basilisk,rawtx,changeaddr,addresses,vals,spendscriptstr) |
||||
|
{ |
||||
|
cJSON *argjson=0,*retjson,*hexjson,*valsobj; char *rawtx=0,*symbol=0; int64_t txfee,satoshis; uint32_t locktime,minconf,basilisktag; int32_t timeout; |
||||
|
//printf("RAWTX changeaddr.%s (%s) remote.(%s)\n",changeaddr==0?"":changeaddr,jprint(json,0),remoteaddr);
|
||||
|
retjson = cJSON_CreateObject(); |
||||
|
if ( spendscriptstr != 0 && spendscriptstr[0] != 0 && (symbol= jstr(vals,"coin")) != 0 ) |
||||
|
{ |
||||
|
minconf = juint(vals,"minconf"); |
||||
|
locktime = juint(vals,"locktime"); |
||||
|
if ( jobj(json,"timeout") != 0 ) |
||||
|
timeout = jint(json,"timeout"); |
||||
|
else timeout = jint(vals,"timeout"); |
||||
|
satoshis = j64bits(vals,"amount"); |
||||
|
txfee = j64bits(vals,"txfee"); |
||||
|
if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) |
||||
|
OS_randombytes((uint8_t *)&basilisktag,sizeof(basilisktag)); |
||||
|
if ( (rawtx= basilisk_issuerawtx(myinfo,remoteaddr,basilisktag,symbol,&argjson,locktime,satoshis,spendscriptstr,changeaddr,txfee,minconf,addresses,timeout)) != 0 ) |
||||
|
{ |
||||
|
//printf("return rawtx.(%s) remote.%p symbol.%s\n",rawtx,remoteaddr,symbol);
|
||||
|
if ( remoteaddr != 0 && remoteaddr[0] != 0 && (coin= iguana_coinfind(symbol)) != 0 ) |
||||
|
{ |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddstr(hexjson,"rawtx",rawtx); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","result"); |
||||
|
if ( argjson != 0 ) |
||||
|
jadd(hexjson,"args",argjson); |
||||
|
valsobj = cJSON_CreateObject(); |
||||
|
jaddstr(valsobj,"coin",symbol); |
||||
|
jadd(hexjson,"vals",valsobj); |
||||
|
retjson = basilisk_json(myinfo,hexjson,basilisktag,timeout); |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
jaddstr(retjson,"result",rawtx); |
||||
|
if ( argjson != 0 ) |
||||
|
jadd(retjson,"args",argjson); |
||||
|
} |
||||
|
free(rawtx); |
||||
|
} else jaddstr(retjson,"error","couldnt create rawtx"); |
||||
|
} |
||||
|
return(jprint(retjson,1)); |
||||
|
} |
||||
|
|
||||
|
INT_ARRAY_STRING(basilisk,result,basilisktag,argjson,hexmsg) |
||||
|
{ |
||||
|
struct basilisk_item *ptr = calloc(1,sizeof(*ptr) + strlen(hexmsg) + 1); |
||||
|
ptr->results[0] = clonestr(hexmsg); |
||||
|
ptr->basilisktag = basilisktag; |
||||
|
if ( argjson != 0 ) |
||||
|
ptr->resultargs[0] = jduplicate(argjson); |
||||
|
ptr->numresults = 1; |
||||
|
queue_enqueue("resultsQ",&myinfo->basilisks.resultsQ,&ptr->DL,0); |
||||
|
return(clonestr("{\"result\":\"queued basilisk return\"}")); |
||||
|
} |
||||
|
|
||||
|
#include "../includes/iguana_apiundefs.h" |
||||
|
|
||||
|
|
||||
|
char *basilisk_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void *ptr,int32_t len,char *remoteaddr) |
||||
|
{ |
||||
|
char *method="",*agent="",*retstr = 0; int32_t i,j; cJSON *vins,*json,*valsobj; struct iguana_info *coin=0; struct iguana_peer *addr; |
||||
|
if ( (json= cJSON_Parse(ptr)) != 0 ) |
||||
|
{ |
||||
|
printf("basilisk.(%s)\n",jprint(json,0)); |
||||
|
agent = jstr(json,"agent"); |
||||
|
method = jstr(json,"method"); |
||||
|
valsobj = jobj(json,"vals"); |
||||
|
if ( strcmp(agent,"basilisk") == 0 ) |
||||
|
{ |
||||
|
if ( valsobj != 0 && jobj(valsobj,"coin") != 0 ) |
||||
|
coin = iguana_coinfind(jstr(valsobj,"coin")); |
||||
|
else if ( jstr(json,"activecoin") != 0 ) |
||||
|
coin = iguana_coinfind(jstr(json,"activecoin")); |
||||
|
if ( coin != 0 ) |
||||
|
{ |
||||
|
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) |
||||
|
{ |
||||
|
if ( valsobj != 0 && strcmp(method,"rawtx") == 0 ) |
||||
|
{ |
||||
|
uint64_t amount = j64bits(valsobj,"amount"); |
||||
|
uint64_t txfee = j64bits(valsobj,"txfee"); |
||||
|
int32_t minconf = juint(valsobj,"minconf"); |
||||
|
int32_t timeout = juint(valsobj,"timeout"); |
||||
|
uint32_t locktime = juint(valsobj,"locktime"); |
||||
|
retstr = basilisk_issuerawtx(myinfo,remoteaddr,0,coin->symbol,&vins,locktime,amount,jstr(json,"spendscriptstr"),jstr(json,"changeaddr"),txfee,minconf,jobj(json,"addresses"),timeout); |
||||
|
} |
||||
|
else if ( strcmp(method,"balances") == 0 ) |
||||
|
{ |
||||
|
retstr = basilisk_balances(myinfo,coin,json,remoteaddr,juint(json,"lastheight"),jobj(json,"addresses"),jstr(json,"activecoin")); |
||||
|
} |
||||
|
if ( retstr == 0 ) |
||||
|
return(0); |
||||
|
printf("basilisk will return.(%s)\n",retstr); |
||||
|
for (j=0; j<IGUANA_MAXCOINS; j++) |
||||
|
{ |
||||
|
if ( (coin= Coins[j]) == 0 ) |
||||
|
continue; |
||||
|
for (i=0; i<IGUANA_MAXPEERS; i++) |
||||
|
{ |
||||
|
if ( (addr= &coin->peers.active[i]) != 0 && addr->usock >= 0 ) |
||||
|
{ |
||||
|
if ( addr->supernet != 0 && strcmp(addr->ipaddr,remoteaddr) == 0 ) |
||||
|
{ |
||||
|
printf("send back basilisk_result addr->supernet.%u to (%s)\n",addr->supernet,addr->ipaddr); |
||||
|
iguana_send_supernet(addr,retstr,0); |
||||
|
free_json(json); |
||||
|
return(retstr); |
||||
|
} |
||||
|
} |
||||
|
if ( 0 && addr->ipbits != 0 ) |
||||
|
printf("i.%d (%s) vs (%s) %s\n",i,addr->ipaddr,remoteaddr,coin->symbol); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if ( strcmp(method,"result") == 0 ) |
||||
|
{ |
||||
|
printf("got rawtx.(%s)\n",jstr(json,"hexmsg")); |
||||
|
return(basilisk_result(myinfo,coin,json,remoteaddr,juint(json,"basilisktag"),jobj(json,"args"),jstr(json,"hexmsg"))); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) |
||||
|
printf("unhandled bitcoin_hexmsg.(%d) from %s (%s/%s)\n",len,remoteaddr,agent,method); |
||||
|
free_json(json); |
||||
|
return(retstr); |
||||
|
} |
||||
|
|
||||
|
void basilisks_loop(void *arg) |
||||
|
{ |
||||
|
struct basilisk_item *ptr,*tmp,*pending; int32_t i,flag,n; struct supernet_info *myinfo = arg; |
||||
|
uint8_t *blockspace; struct OS_memspace RAWMEM; struct iguana_info *coin; |
||||
|
memset(&RAWMEM,0,sizeof(RAWMEM)); |
||||
|
blockspace = calloc(1,IGUANA_MAXPACKETSIZE); |
||||
|
while ( 1 ) |
||||
|
{ |
||||
|
for (i=0; i<IGUANA_MAXCOINS; i++) |
||||
|
if ( (coin= Coins[i]) != 0 && coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 ) |
||||
|
basilisk_bitcoinscan(coin,blockspace,&RAWMEM); |
||||
|
if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 ) |
||||
|
{ |
||||
|
if ( ptr->finished == 0 ) |
||||
|
HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr); |
||||
|
else free(ptr); |
||||
|
continue; |
||||
|
} |
||||
|
else if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 ) |
||||
|
{ |
||||
|
HASH_FIND(hh,myinfo->basilisks.issued,&ptr->basilisktag,sizeof(ptr->basilisktag),pending); |
||||
|
if ( pending != 0 ) |
||||
|
{ |
||||
|
if ( (n= pending->numresults) < sizeof(pending->results)/sizeof(*pending->results) ) |
||||
|
{ |
||||
|
pending->results[n] = ptr->results[0]; |
||||
|
pending->resultargs[n] = ptr->resultargs[0]; |
||||
|
pending->numresults++; |
||||
|
} |
||||
|
} |
||||
|
free(ptr); |
||||
|
continue; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
flag = 0; |
||||
|
HASH_ITER(hh,myinfo->basilisks.issued,ptr,tmp) |
||||
|
{ |
||||
|
if ( ptr->finished != 0 ) |
||||
|
{ |
||||
|
HASH_DELETE(hh,myinfo->basilisks.issued,ptr); |
||||
|
free(ptr); |
||||
|
flag++; |
||||
|
} |
||||
|
} |
||||
|
if ( flag == 0 ) |
||||
|
usleep(100000); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void basilisks_init(struct supernet_info *myinfo) |
||||
|
{ |
||||
|
bits256 basiliskhash; |
||||
|
iguana_initQ(&myinfo->basilisks.submitQ,"submitQ"); |
||||
|
iguana_initQ(&myinfo->basilisks.resultsQ,"resultsQ"); |
||||
|
basiliskhash = calc_categoryhashes(0,"basilisk",0); |
||||
|
myinfo->basilisk_category = basiliskhash; |
||||
|
category_subscribe(myinfo,basiliskhash,GENESIS_PUBKEY); |
||||
|
category_processfunc(basiliskhash,GENESIS_PUBKEY,basilisk_hexmsg); |
||||
|
category_processfunc(basiliskhash,myinfo->myaddr.persistent,basilisk_hexmsg); |
||||
|
myinfo->basilisks.launched = iguana_launch(iguana_coinfind("BTCD"),"basilisks_loop",basilisks_loop,myinfo,IGUANA_PERMTHREAD); |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
#ifndef H_BASILISK_H |
||||
|
#define H_BASILISK_H |
||||
|
|
||||
|
#include "../iguana/iguana777.h" |
||||
|
|
||||
|
#define BASILISK_TIMEOUT 30000 |
||||
|
#define BASILISK_MINFANOUT 8 |
||||
|
#define BASILISK_MAXFANOUT 64 |
||||
|
|
||||
|
struct basilisk_value { bits256 txid; int64_t value; int16_t vout; char coinaddr[64]; }; |
||||
|
|
||||
|
struct basilisk_item |
||||
|
{ |
||||
|
struct queueitem DL; UT_hash_handle hh; |
||||
|
uint32_t submit,finished,basilisktag,numresults,numexact; |
||||
|
char *results[BASILISK_MAXFANOUT]; cJSON *resultargs[BASILISK_MAXFANOUT]; |
||||
|
}; |
||||
|
|
||||
|
struct basilisk_info |
||||
|
{ |
||||
|
queue_t resultsQ,submitQ; void *launched; //portable_mutex_t *mutex;
|
||||
|
struct basilisk_item *issued; |
||||
|
struct basilisk_value values[8192]; int32_t numvalues; |
||||
|
}; |
||||
|
|
||||
|
struct basilisk_item *basilisk_issue(struct supernet_info *myinfo,cJSON *hexjson,int32_t timeoutmillis,int32_t fanout,int32_t minresults,uint32_t basilisktag); |
||||
|
void basilisks_init(struct supernet_info *myinfo); |
||||
|
char *basilisk_issuerawtx(struct supernet_info *myinfo,char *remoteaddr,uint32_t basilisktag,char *symbol,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *spendscriptstr,char *changeaddr,int64_t txfee,int32_t minconf,cJSON *addresses,int32_t timeout); |
||||
|
|
||||
|
#endif |
@ -0,0 +1,487 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
#ifdef bitcoincancalculatebalances |
||||
|
int64_t bitcoin_value(struct iguana_info *coin,bits256 txid,int16_t vout,char *coinaddr) |
||||
|
{ |
||||
|
char params[512],str[65]; char *curlstr; cJSON *txobj,*vouts,*item,*sobj,*addrs; int32_t j,m,n; int64_t value = 0; |
||||
|
sprintf(params,"[\"%s\", 1]",bits256_str(str,txid)); |
||||
|
if ( (curlstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getrawtransaction",params)) != 0 ) |
||||
|
{ |
||||
|
if ( (txobj= cJSON_Parse(curlstr)) != 0 ) |
||||
|
{ |
||||
|
if ( (vouts= jarray(&n,txobj,"vout")) != 0 && vout < n ) |
||||
|
{ |
||||
|
item = jitem(vouts,vout); |
||||
|
if ( (sobj= jobj(item,"scriptPubKey")) != 0 && (addrs= jarray(&m,sobj,"addresses")) != 0 ) |
||||
|
{ |
||||
|
for (j=0; j<m; j++) |
||||
|
{ |
||||
|
if ( strcmp(jstri(addrs,j),coinaddr) == 0 ) |
||||
|
{ |
||||
|
value = SATOSHIDEN * jdouble(item,"amount"); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
free_json(txobj); |
||||
|
} |
||||
|
free(curlstr); |
||||
|
} |
||||
|
return(value); |
||||
|
} |
||||
|
|
||||
|
char *bitcoin_balance(struct iguana_info *coin,char *coinaddr,int32_t lastheight,int32_t minconf) |
||||
|
{ |
||||
|
int32_t i,n,height,maxconf=1<<30; int64_t balance = 0; char params[512],*curlstr; cJSON *array,*retjson,*curljson; |
||||
|
retjson = cJSON_CreateObject(); |
||||
|
if ( (curlstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getinfo",params)) != 0 ) |
||||
|
{ |
||||
|
if ( (curljson= cJSON_Parse(curlstr)) != 0 ) |
||||
|
{ |
||||
|
if ( (height= juint(curljson,"blocks")) > lastheight ) |
||||
|
maxconf = height - lastheight; |
||||
|
free_json(curljson); |
||||
|
} |
||||
|
free(curlstr); |
||||
|
} |
||||
|
sprintf(params,"%d, %d, [\"%s\"]",minconf,maxconf,coinaddr); |
||||
|
if ( (curlstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listunspent",params)) != 0 ) |
||||
|
{ |
||||
|
if ( (array= cJSON_Parse(curlstr)) != 0 ) |
||||
|
{ |
||||
|
if ( (n= cJSON_GetArraySize(array)) > 0 ) |
||||
|
{ |
||||
|
for (i=0; i<n; i++) |
||||
|
balance += SATOSHIDEN * jdouble(jitem(array,i),"amount"); |
||||
|
} |
||||
|
free_json(array); |
||||
|
} |
||||
|
free(curlstr); |
||||
|
} |
||||
|
jaddnum(retjson,"balance",dstr(balance)); |
||||
|
return(jprint(retjson,1)); |
||||
|
} |
||||
|
#else |
||||
|
|
||||
|
char *bitcoin_blockhashstr(char *coinstr,char *serverport,char *userpass,int32_t height) |
||||
|
{ |
||||
|
char numstr[128],*blockhashstr=0; |
||||
|
sprintf(numstr,"%d",height); |
||||
|
blockhashstr = bitcoind_passthru(coinstr,serverport,userpass,"getblockhash",numstr); |
||||
|
if ( blockhashstr == 0 || blockhashstr[0] == 0 ) |
||||
|
{ |
||||
|
printf("couldnt get blockhash for %u\n",height); |
||||
|
if ( blockhashstr != 0 ) |
||||
|
free(blockhashstr); |
||||
|
return(0); |
||||
|
} |
||||
|
return(blockhashstr); |
||||
|
} |
||||
|
|
||||
|
cJSON *bitcoin_blockjson(int32_t *heightp,char *coinstr,char *serverport,char *userpass,char *blockhashstr,int32_t height) |
||||
|
{ |
||||
|
cJSON *json = 0; int32_t flag = 0; char buf[1024],*blocktxt = 0; |
||||
|
if ( blockhashstr == 0 ) |
||||
|
blockhashstr = bitcoin_blockhashstr(coinstr,serverport,userpass,height), flag = 1; |
||||
|
if ( blockhashstr != 0 ) |
||||
|
{ |
||||
|
sprintf(buf,"\"%s\"",blockhashstr); |
||||
|
blocktxt = bitcoind_passthru(coinstr,serverport,userpass,"getblock",buf); |
||||
|
//printf("get_blockjson.(%d %s) %s\n",height,blockhashstr,blocktxt);
|
||||
|
if ( blocktxt != 0 && blocktxt[0] != 0 && (json= cJSON_Parse(blocktxt)) != 0 && heightp != 0 ) |
||||
|
if ( (*heightp= juint(json,"height")) != height ) |
||||
|
*heightp = -1; |
||||
|
if ( flag != 0 && blockhashstr != 0 ) |
||||
|
free(blockhashstr); |
||||
|
if ( blocktxt != 0 ) |
||||
|
free(blocktxt); |
||||
|
} |
||||
|
return(json); |
||||
|
} |
||||
|
|
||||
|
int32_t basilisk_bitcoinscan(struct iguana_info *coin,uint8_t origblockspace[IGUANA_MAXPACKETSIZE],struct OS_memspace *rawmem) |
||||
|
{ |
||||
|
struct iguana_txblock txdata; int32_t len,starti,h,num=0,loadheight,hexlen,datalen,n,i,numtxids,flag=0,height=-1; cJSON *curljson,*blockjson,*txids; char *bitstr,*curlstr,params[128],str[65]; struct iguana_msghdr H; struct iguana_msgblock *msg; uint8_t *blockspace,revbits[4],bitsbuf[4]; |
||||
|
strcpy(params,"[]"); |
||||
|
if ( (curlstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getinfo",params)) != 0 ) |
||||
|
{ |
||||
|
if ( (curljson= cJSON_Parse(curlstr)) != 0 ) |
||||
|
{ |
||||
|
height = juint(curljson,"blocks"); |
||||
|
free_json(curljson); |
||||
|
} |
||||
|
free(curlstr); |
||||
|
} |
||||
|
loadheight = coin->blocks.hwmchain.height; |
||||
|
if ( loadheight == 0 ) |
||||
|
loadheight = 1; |
||||
|
while ( loadheight <= height )//&& coin->blocks.pending < 10 )
|
||||
|
{ |
||||
|
flag = 0; |
||||
|
if ( (blockjson= bitcoin_blockjson(&h,coin->symbol,coin->chain->serverport,coin->chain->userpass,0,loadheight)) != 0 ) |
||||
|
{ |
||||
|
blockspace = origblockspace; |
||||
|
msg = (void *)blockspace; |
||||
|
memset(msg,0,sizeof(*msg)); |
||||
|
msg->H.version = juint(blockjson,"version"); |
||||
|
msg->H.prev_block = jbits256(blockjson,"previousblockhash"); |
||||
|
msg->H.merkle_root = jbits256(blockjson,"merkleroot"); |
||||
|
msg->H.timestamp = juint(blockjson,"timestamp"); |
||||
|
if ( (bitstr= jstr(blockjson,"bits")) != 0 ) |
||||
|
{ |
||||
|
decode_hex(revbits,sizeof(revbits),bitstr); |
||||
|
for (i=0; i<4; i++) |
||||
|
bitsbuf[i] = revbits[3 - i]; |
||||
|
memcpy(&msg->H.bits,bitsbuf,sizeof(msg->H.bits)); |
||||
|
} |
||||
|
msg->H.nonce = juint(blockjson,"nonce"); |
||||
|
datalen = 80; |
||||
|
if ( (txids= jarray(&numtxids,blockjson,"tx")) != 0 ) |
||||
|
{ |
||||
|
msg->txn_count = numtxids; |
||||
|
if ( numtxids < 0xfd ) |
||||
|
blockspace[datalen++] = numtxids; |
||||
|
else |
||||
|
{ |
||||
|
blockspace[datalen++] = 0xfd; |
||||
|
blockspace[datalen++] = numtxids & 0xff; |
||||
|
blockspace[datalen++] = numtxids >> 8; |
||||
|
} |
||||
|
starti = datalen; |
||||
|
for (i=0; i<numtxids; i++) |
||||
|
{ |
||||
|
sprintf(params,"[\"%s\"]",bits256_str(str,jbits256(jitem(txids,i),0))); |
||||
|
if ( (curlstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getrawtransaction",params)) != 0 ) |
||||
|
{ |
||||
|
//printf("%s txid.%d\n",curlstr,i);
|
||||
|
if ( (hexlen= is_hexstr(curlstr,0)) > 1 ) |
||||
|
{ |
||||
|
hexlen >>= 1; |
||||
|
decode_hex(&blockspace[datalen],hexlen,curlstr); |
||||
|
datalen += hexlen; |
||||
|
} |
||||
|
free(curlstr); |
||||
|
} |
||||
|
} |
||||
|
num++; |
||||
|
coin->blocks.pending++; |
||||
|
if ( rawmem->ptr == 0 ) |
||||
|
iguana_meminit(rawmem,"basilisk",0,IGUANA_MAXPACKETSIZE*3,0); |
||||
|
else iguana_memreset(rawmem); |
||||
|
memset(&txdata,0,sizeof(txdata)); |
||||
|
memset(&H,0,sizeof(H)); |
||||
|
if ( (n= iguana_gentxarray(coin,rawmem,&txdata,&len,blockspace,datalen)) == datalen ) |
||||
|
{ |
||||
|
len = n; |
||||
|
iguana_gotblockM(coin,0,&txdata,rawmem->ptr,&H,blockspace,datalen); |
||||
|
flag = 1; |
||||
|
//if ( (rand() % 1000) == 0 )
|
||||
|
printf("%s height.%-7d datalen.%-6d | HWM.%d\n",coin->symbol,h,datalen,coin->blocks.hwmchain.height); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
printf(" parse error block.%d txn_count.%d, n.%d len.%d vs datalen.%d\n",loadheight,txdata.block.RO.txn_count,n,len,datalen); |
||||
|
} |
||||
|
} |
||||
|
free_json(blockjson); |
||||
|
} |
||||
|
if ( flag == 0 ) |
||||
|
break; |
||||
|
loadheight++; |
||||
|
} |
||||
|
if ( coin->blocks.pending > 0 ) |
||||
|
coin->blocks.pending--; |
||||
|
return(num); |
||||
|
} |
||||
|
|
||||
|
#endif |
||||
|
|
||||
|
int32_t basilisk_bitcoinavail(struct iguana_info *coin) |
||||
|
{ |
||||
|
if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 ) |
||||
|
return(1); |
||||
|
//else if ( coin->chain->serverport[0] != 0 )
|
||||
|
// return(1);
|
||||
|
else return(0); |
||||
|
} |
||||
|
|
||||
|
int64_t basilisk_bitcoinbalances(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,cJSON **arrayp,int32_t lastheight,int32_t minconf,cJSON *addresses,int32_t timeoutmillis) |
||||
|
{ |
||||
|
cJSON *array=0,*result,*item,*retjson,*hexjson; int32_t i,n,besti=-1; char *coinaddr,*balancestr=0,*retstr=0; int64_t total=0,amount,most=0; struct basilisk_item *ptr; |
||||
|
array = cJSON_CreateArray(); |
||||
|
if ( coin != 0 && basilisk_bitcoinavail(coin) != 0 ) |
||||
|
{ |
||||
|
if ( (n= cJSON_GetArraySize(addresses)) > 0 ) |
||||
|
{ |
||||
|
for (i=0; i<n; i++) |
||||
|
{ |
||||
|
coinaddr = jstri(addresses,i); |
||||
|
if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 ) |
||||
|
balancestr = iguana_balance(myinfo,coin,0,remoteaddr,coin->symbol,coinaddr,lastheight,minconf); |
||||
|
//else balancestr = bitcoin_balance(coin,coinaddr,lastheight,minconf);
|
||||
|
if ( balancestr != 0 ) |
||||
|
{ |
||||
|
if ( (result= cJSON_Parse(balancestr)) != 0 ) |
||||
|
{ |
||||
|
if ( jobj(result,"balance") != 0 ) |
||||
|
{ |
||||
|
item = cJSON_CreateObject(); |
||||
|
amount = SATOSHIDEN * jdouble(result,"balance"); |
||||
|
total += amount; |
||||
|
jaddnum(item,coinaddr,dstr(amount)); |
||||
|
jaddi(array,item); |
||||
|
} |
||||
|
free_json(result); |
||||
|
} |
||||
|
free(balancestr); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddnum(hexjson,"basilisktag",basilisktag); |
||||
|
jadd(hexjson,"addresses",jduplicate(addresses)); |
||||
|
jaddnum(hexjson,"minconf",minconf); |
||||
|
jaddnum(hexjson,"lastheight",lastheight); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","balances"); |
||||
|
if ( (ptr= basilisk_issue(myinfo,hexjson,timeoutmillis,0,1,basilisktag)) != 0 ) |
||||
|
{ |
||||
|
for (i=0; i<ptr->numresults; i++) |
||||
|
{ |
||||
|
if ( ptr->results[i] == 0 ) |
||||
|
continue; |
||||
|
if ( retstr != 0 && strcmp(ptr->results[i],retstr) == 0 ) |
||||
|
ptr->numexact++; |
||||
|
if ( (retjson= cJSON_Parse(ptr->results[i])) != 0 ) |
||||
|
{ |
||||
|
if ( (total= j64bits(retjson,"balance")) > most ) |
||||
|
{ |
||||
|
most = total; |
||||
|
besti = i; |
||||
|
} |
||||
|
free_json(retjson); |
||||
|
} |
||||
|
} |
||||
|
retstr = basilisk_finish(ptr,arrayp,besti); |
||||
|
} |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
*arrayp = array; |
||||
|
return(most); |
||||
|
} |
||||
|
|
||||
|
int64_t basilisk_bitcoinvalue(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,bits256 txid,int32_t vout,char *coinaddr,int32_t timeoutmillis) |
||||
|
{ |
||||
|
int32_t i,height; struct basilisk_value *v; cJSON *hexjson; uint64_t value = 0; struct basilisk_item *ptr; |
||||
|
if ( coin != 0 && basilisk_bitcoinavail(coin) != 0 ) |
||||
|
{ |
||||
|
if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 ) |
||||
|
{ |
||||
|
if ( iguana_unspentindfind(coin,coinaddr,0,0,&value,&height,txid,vout,coin->bundlescount) > 0 ) |
||||
|
return(value); |
||||
|
} //else return(bitcoin_value(coin,txid,vout,coinaddr));
|
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if ( (v= myinfo->basilisks.values) != 0 ) |
||||
|
{ |
||||
|
for (i=0; i<myinfo->basilisks.numvalues; i++,v++) |
||||
|
{ |
||||
|
if ( v->vout == vout && bits256_cmp(txid,v->txid) == 0 && strcmp(v->coinaddr,coinaddr) == 0 ) |
||||
|
return(v->value); |
||||
|
} |
||||
|
} |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddnum(hexjson,"basilisktag",basilisktag); |
||||
|
jaddstr(hexjson,"address",coinaddr); |
||||
|
jaddbits256(hexjson,"txid",txid); |
||||
|
jaddnum(hexjson,"vout",vout); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","value"); |
||||
|
if ( (ptr= basilisk_issue(myinfo,hexjson,timeoutmillis,0,1,basilisktag)) != 0 ) |
||||
|
{ |
||||
|
v = &myinfo->basilisks.values[myinfo->basilisks.numvalues++]; |
||||
|
strcpy(v->coinaddr,coinaddr); |
||||
|
v->value = value; |
||||
|
v->txid = txid; |
||||
|
} |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
return(value); |
||||
|
} |
||||
|
|
||||
|
int64_t basilisk_bitcointxcost(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t locktime,int64_t satoshis,int64_t txfee,cJSON *addresses,char *spendscriptstr,char *changeaddr,char *rawtx,cJSON *vins) |
||||
|
{ |
||||
|
cJSON *txobj,*vouts,*vin,*sobj,*addrs; int64_t change=0,outputsum=0,inputsum=0,spentsatoshis=0,cost = -1; int32_t i,j,m,numaddrs,spendlen,n; struct iguana_msgtx msgtx; uint8_t extraspace[8192],script[IGUANA_MAXSCRIPTSIZE],asmtype; struct vin_info V; char *scriptstr,str[65]; bits256 txid; |
||||
|
if ( coin != 0 ) |
||||
|
{ |
||||
|
spendlen = (int32_t)strlen(spendscriptstr) >> 1; |
||||
|
decode_hex(script,spendlen,spendscriptstr); |
||||
|
if ( (txobj= bitcoin_hex2json(coin,&txid,&msgtx,rawtx,extraspace,sizeof(extraspace))) != 0 ) |
||||
|
{ |
||||
|
if ( juint(txobj,"locktime") != locktime ) |
||||
|
{ |
||||
|
printf("locktime mismatch %u != %u\n",juint(txobj,"locktime"),locktime); |
||||
|
return(-1); |
||||
|
} |
||||
|
else if ( jobj(txobj,"error") == 0 && (vins= jarray(&n,txobj,"vin")) != 0 && cJSON_GetArraySize(vins) == msgtx.tx_in ) |
||||
|
{ |
||||
|
numaddrs = cJSON_GetArraySize(addresses); |
||||
|
for (i=0; i<msgtx.tx_in; i++) |
||||
|
{ |
||||
|
vin = jitem(vins,i); |
||||
|
if ( (sobj= jobj(vin,"scriptPubKey")) != 0 && (scriptstr= jstr(sobj,"hex")) != 0 ) |
||||
|
{ |
||||
|
memset(&V,0,sizeof(V)); |
||||
|
V.spendlen = (int32_t)strlen(scriptstr) >> 1; |
||||
|
decode_hex(V.spendscript,V.spendlen,scriptstr); |
||||
|
asmtype = _iguana_calcrmd160(coin,&V); |
||||
|
if ( basilisk_bitcoinvalue(myinfo,coin,remoteaddr,0,msgtx.vins[i].prev_hash,msgtx.vins[i].prev_vout,V.coinaddr,10000) == V.amount ) |
||||
|
{ |
||||
|
inputsum += V.amount; |
||||
|
for (j=0; j<numaddrs; j++) |
||||
|
if ( strcmp(jstri(addresses,j),V.coinaddr) == 0 ) |
||||
|
break; |
||||
|
if ( j == numaddrs ) |
||||
|
{ |
||||
|
printf("spend of invalid input address.(%s)\n",V.coinaddr); |
||||
|
free_json(txobj); |
||||
|
return(-1); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
printf("spend of invalid %s unspent.(%s).%d\n",V.coinaddr,bits256_str(str,msgtx.vins[i].prev_hash),msgtx.vins[i].prev_vout); |
||||
|
free_json(txobj); |
||||
|
return(-1); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if ( (vouts= jarray(&n,txobj,"vout")) != 0 && n == msgtx.tx_out ) |
||||
|
{ |
||||
|
for (i=0; i<msgtx.tx_out; i++) |
||||
|
{ |
||||
|
outputsum += msgtx.vouts[i].value; |
||||
|
if ( spendlen == msgtx.vouts[i].pk_scriptlen && memcmp(script,msgtx.vouts[i].pk_script,spendlen) == 0 ) |
||||
|
{ |
||||
|
spentsatoshis = msgtx.vouts[i].value; |
||||
|
continue; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if ( (sobj= jobj(jitem(vouts,i),"scriptPubKey")) != 0 && (addrs= jarray(&m,sobj,"addresses")) != 0 ) |
||||
|
{ |
||||
|
if ( m == 1 && strcmp(jstri(addrs,0),changeaddr) == 0 ) |
||||
|
{ |
||||
|
change = msgtx.vouts[i].value; |
||||
|
printf("verify it is normal spend for %s\n",changeaddr); |
||||
|
continue; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
cost += msgtx.vouts[i].value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
free_json(txobj); |
||||
|
} |
||||
|
} |
||||
|
if ( spentsatoshis != satoshis ) |
||||
|
{ |
||||
|
printf("spentsatoshis %.8f != expected %.8f, change %.8f\n",dstr(spentsatoshis),dstr(satoshis),dstr(change)); |
||||
|
return(-1); |
||||
|
} |
||||
|
if ( (inputsum - outputsum) != txfee ) |
||||
|
{ |
||||
|
printf("inputsum %.8f - outputsum %.8f = %.8f != txfee %.8f\n",dstr(inputsum),dstr(outputsum),dstr(inputsum)-dstr(outputsum),dstr(txfee)); |
||||
|
return(-1); |
||||
|
} |
||||
|
return(cost); |
||||
|
} |
||||
|
|
||||
|
char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *changeaddr,uint64_t txfee,cJSON *addresses,int32_t minconf,char *spendscriptstr,int32_t timeoutmillis) |
||||
|
{ |
||||
|
uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t i,spendlen,besti=-1; cJSON *hexjson,*valsobj,*txobj = 0; char *retstr=0,*rawtx = 0; int64_t cost,bestcost=-1; struct basilisk_item *ptr; |
||||
|
*vinsp = 0; |
||||
|
if ( coin != 0 && basilisk_bitcoinavail(coin) != 0 ) |
||||
|
{ |
||||
|
if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 ) |
||||
|
{ |
||||
|
if ( txfee == 0 ) |
||||
|
txfee = coin->chain->txfee; |
||||
|
if ( (txobj= bitcoin_txcreate(coin,locktime)) != 0 ) |
||||
|
{ |
||||
|
spendlen = (int32_t)strlen(spendscriptstr) >> 1; |
||||
|
decode_hex(buf,spendlen,spendscriptstr); |
||||
|
bitcoin_txoutput(coin,txobj,buf,spendlen,satoshis); |
||||
|
rawtx = iguana_calcrawtx(myinfo,coin,vinsp,txobj,satoshis,changeaddr,txfee,addresses,minconf); |
||||
|
} else printf("error creating txobj\n"); |
||||
|
} //else rawtx = bitcoin_calcrawtx(myinfo,coin,vinsp,satoshis,spendscriptstr,changeaddr,txfee,addresses,minconf,locktime);
|
||||
|
if ( rawtx != 0 ) |
||||
|
{ |
||||
|
if ( *vinsp != 0 ) |
||||
|
{ |
||||
|
free_json(txobj); |
||||
|
//printf("return locally generated rawtx.(%s) vins.%p\n",rawtx,*vinsp);
|
||||
|
return(rawtx); |
||||
|
} else free(rawtx); |
||||
|
} |
||||
|
} |
||||
|
if ( txobj != 0 ) |
||||
|
free_json(txobj); |
||||
|
if ( addresses != 0 ) |
||||
|
{ |
||||
|
valsobj = cJSON_CreateObject(); |
||||
|
jaddnum(valsobj,"basilisktag",basilisktag); |
||||
|
jaddstr(valsobj,"coin",coin->symbol); |
||||
|
jadd64bits(valsobj,"amount",satoshis); |
||||
|
jadd64bits(valsobj,"txfee",txfee); |
||||
|
jaddnum(valsobj,"minconf",minconf); |
||||
|
jaddnum(valsobj,"locktime",locktime); |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddstr(hexjson,"changeaddr",changeaddr); |
||||
|
jaddstr(hexjson,"spendscriptstr",spendscriptstr); |
||||
|
jadd(hexjson,"addresses",jduplicate(addresses)); |
||||
|
jadd(hexjson,"vals",valsobj); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","rawtx"); |
||||
|
if ( (ptr= basilisk_issue(myinfo,hexjson,timeoutmillis,0,1,basilisktag)) != 0 ) |
||||
|
{ |
||||
|
for (i=0; i<ptr->numresults; i++) |
||||
|
{ |
||||
|
if ( ptr->results[i] == 0 ) |
||||
|
continue; |
||||
|
if ( retstr != 0 && strcmp(ptr->results[i],retstr) == 0 ) |
||||
|
ptr->numexact++; |
||||
|
if ( (cost= basilisk_bitcointxcost(myinfo,coin,remoteaddr,locktime,satoshis,txfee,addresses,spendscriptstr,changeaddr,ptr->results[i],ptr->resultargs[i])) >= 0 && (bestcost == 0 || cost < bestcost) ) |
||||
|
{ |
||||
|
if ( retstr != 0 ) |
||||
|
ptr->numexact = 0; |
||||
|
retstr = ptr->results[i]; |
||||
|
bestcost = cost; |
||||
|
besti = i; |
||||
|
} |
||||
|
} |
||||
|
retstr = basilisk_finish(ptr,vinsp,besti); |
||||
|
} |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
return(retstr); |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
char *basilisk_etherrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *changeaddr,uint64_t txfee,cJSON *addresses,int32_t minconf,char *spendscriptstr,int32_t timeoutmillis) |
||||
|
{ |
||||
|
cJSON *hexjson,*valsobj; char *retstr = 0; struct basilisk_item *ptr; |
||||
|
*vinsp = 0; |
||||
|
if ( addresses != 0 ) |
||||
|
{ |
||||
|
valsobj = cJSON_CreateObject(); |
||||
|
jaddnum(valsobj,"basilisktag",basilisktag); |
||||
|
jaddstr(valsobj,"coin",coin->symbol); |
||||
|
jadd64bits(valsobj,"amount",satoshis); |
||||
|
jadd64bits(valsobj,"txfee",txfee); |
||||
|
jaddnum(valsobj,"minconf",minconf); |
||||
|
jaddnum(valsobj,"locktime",locktime); |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddstr(hexjson,"changeaddr",changeaddr); |
||||
|
jaddstr(hexjson,"spendscriptstr",spendscriptstr); |
||||
|
jadd(hexjson,"addresses",jduplicate(addresses)); |
||||
|
jadd(hexjson,"vals",valsobj); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","rawtx"); |
||||
|
if ( (ptr= basilisk_issue(myinfo,hexjson,timeoutmillis,0,1,basilisktag)) != 0 ) |
||||
|
retstr = basilisk_finish(ptr,vinsp,0); |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
return(retstr); |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
char *basilisk_iotarawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *changeaddr,uint64_t txfee,cJSON *addresses,int32_t minconf,char *spendscriptstr,int32_t timeoutmillis) |
||||
|
{ |
||||
|
cJSON *hexjson,*valsobj; char *retstr = 0; struct basilisk_item *ptr; |
||||
|
*argsjsonp = 0; |
||||
|
if ( addresses != 0 ) |
||||
|
{ |
||||
|
valsobj = cJSON_CreateObject(); |
||||
|
jaddnum(valsobj,"basilisktag",basilisktag); |
||||
|
jaddstr(valsobj,"coin",symbol); |
||||
|
jadd64bits(valsobj,"amount",satoshis); |
||||
|
jadd64bits(valsobj,"txfee",txfee); |
||||
|
jaddnum(valsobj,"minconf",minconf); |
||||
|
jaddnum(valsobj,"locktime",locktime); |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddstr(hexjson,"changeaddr",changeaddr); |
||||
|
jaddstr(hexjson,"spendscriptstr",spendscriptstr); |
||||
|
jadd(hexjson,"addresses",jduplicate(addresses)); |
||||
|
jadd(hexjson,"vals",valsobj); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","rawtx"); |
||||
|
if ( (ptr= basilisk_issue(myinfo,hexjson,timeoutmillis,0,1,basilisktag)) != 0 ) |
||||
|
retstr = basilisk_finish(ptr,argsjsonp,0); |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
return(retstr); |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
char *basilisk_liskrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *changeaddr,uint64_t txfee,cJSON *addresses,int32_t minconf,char *spendscriptstr,int32_t timeoutmillis) |
||||
|
{ |
||||
|
cJSON *hexjson,*valsobj; char *retstr = 0; struct basilisk_item *ptr; |
||||
|
*vinsp = 0; |
||||
|
if ( addresses != 0 ) |
||||
|
{ |
||||
|
valsobj = cJSON_CreateObject(); |
||||
|
jaddnum(valsobj,"basilisktag",basilisktag); |
||||
|
jaddstr(valsobj,"coin",coin->symbol); |
||||
|
jadd64bits(valsobj,"amount",satoshis); |
||||
|
jadd64bits(valsobj,"txfee",txfee); |
||||
|
jaddnum(valsobj,"minconf",minconf); |
||||
|
jaddnum(valsobj,"locktime",locktime); |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddstr(hexjson,"changeaddr",changeaddr); |
||||
|
jaddstr(hexjson,"spendscriptstr",spendscriptstr); |
||||
|
jadd(hexjson,"addresses",jduplicate(addresses)); |
||||
|
jadd(hexjson,"vals",valsobj); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","rawtx"); |
||||
|
if ( (ptr= basilisk_issue(myinfo,hexjson,timeoutmillis,0,1,basilisktag)) != 0 ) |
||||
|
retstr = basilisk_finish(ptr,vinsp,0); |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
return(retstr); |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
char *basilisk_nxtrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *changeaddr,uint64_t txfee,cJSON *addresses,int32_t minconf,char *spendscriptstr,int32_t timeoutmillis) |
||||
|
{ |
||||
|
cJSON *hexjson,*valsobj; char *retstr = 0; struct basilisk_item *ptr; |
||||
|
*vinsp = 0; |
||||
|
if ( addresses != 0 ) |
||||
|
{ |
||||
|
valsobj = cJSON_CreateObject(); |
||||
|
jaddnum(valsobj,"basilisktag",basilisktag); |
||||
|
jaddstr(valsobj,"coin",coin->symbol); |
||||
|
jadd64bits(valsobj,"amount",satoshis); |
||||
|
jadd64bits(valsobj,"txfee",txfee); |
||||
|
jaddnum(valsobj,"minconf",minconf); |
||||
|
jaddnum(valsobj,"locktime",locktime); |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddstr(hexjson,"changeaddr",changeaddr); |
||||
|
jaddstr(hexjson,"spendscriptstr",spendscriptstr); |
||||
|
jadd(hexjson,"addresses",jduplicate(addresses)); |
||||
|
jadd(hexjson,"vals",valsobj); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","rawtx"); |
||||
|
if ( (ptr= basilisk_issue(myinfo,hexjson,timeoutmillis,0,1,basilisktag)) != 0 ) |
||||
|
retstr = basilisk_finish(ptr,vinsp,0); |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
return(retstr); |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
/******************************************************************************
|
||||
|
* Copyright © 2014-2016 The SuperNET Developers. * |
||||
|
* * |
||||
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
||||
|
* the top-level directory of this distribution for the individual copyright * |
||||
|
* holder information and the developer policies on copyright and licensing. * |
||||
|
* * |
||||
|
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
||||
|
* SuperNET software, including this file may be copied, modified, propagated * |
||||
|
* or distributed except according to the terms contained in the LICENSE file * |
||||
|
* * |
||||
|
* Removal or modification of this copyright notice is prohibited. * |
||||
|
* * |
||||
|
******************************************************************************/ |
||||
|
|
||||
|
char *basilisk_wavesrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *changeaddr,uint64_t txfee,cJSON *addresses,int32_t minconf,char *spendscriptstr,int32_t timeoutmillis) |
||||
|
{ |
||||
|
cJSON *hexjson,*valsobj; char *retstr = 0; struct basilisk_item *ptr; |
||||
|
*vinsp = 0; |
||||
|
if ( addresses != 0 ) |
||||
|
{ |
||||
|
valsobj = cJSON_CreateObject(); |
||||
|
jaddnum(valsobj,"basilisktag",basilisktag); |
||||
|
jaddstr(valsobj,"coin",coin->symbol); |
||||
|
jadd64bits(valsobj,"amount",satoshis); |
||||
|
jadd64bits(valsobj,"txfee",txfee); |
||||
|
jaddnum(valsobj,"minconf",minconf); |
||||
|
jaddnum(valsobj,"locktime",locktime); |
||||
|
hexjson = cJSON_CreateObject(); |
||||
|
jaddstr(hexjson,"changeaddr",changeaddr); |
||||
|
jaddstr(hexjson,"spendscriptstr",spendscriptstr); |
||||
|
jadd(hexjson,"addresses",jduplicate(addresses)); |
||||
|
jadd(hexjson,"vals",valsobj); |
||||
|
jaddstr(hexjson,"agent","basilisk"); |
||||
|
jaddstr(hexjson,"method","rawtx"); |
||||
|
if ( (ptr= basilisk_issue(myinfo,hexjson,timeoutmillis,0,1,basilisktag)) != 0 ) |
||||
|
retstr = basilisk_finish(ptr,vinsp,0); |
||||
|
free_json(hexjson); |
||||
|
} |
||||
|
return(retstr); |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
git pull |
||||
|
rm *.o |
||||
|
gcc -c -DLIQUIDITY_PROVIDER -O2 *.c jpeg/*.c jpeg/unix/*.c -I/usr/lib/x86_64-linux-gnu/curl |
||||
|
rm -f ../agents/libcrypto777.a; ar rcu ../agents/libcrypto777.a *.o |
@ -1,2 +1,2 @@ |
|||||
|
|
||||
SOURCES := SuperNET.c iguana_bundles.c iguana_stake.c iguana_interpreter.c mini-gmp.c main.c iguana_payments.c iguana_spendvectors.c iguana_sign.c iguana_txidfind.c iguana_realtime.c iguana_volatiles.c peggy_price.c SuperNET_category.c iguana_chains.c iguana_ramchain.c iguana_secp.c pangea_api.c peggy_ramkv.c SuperNET_hexmsg.c iguana_exchanges.c iguana_recv.c pangea_bets.c peggy_serdes.c SuperNET_keys.c iguana_rpc.c pangea_hand.c peggy_tx.c cards777.c iguana_init.c iguana_scripts.c pangea_json.c peggy_txind.c iguana777.c iguana_instantdex.c iguana_tradebots.c pangea_summary.c peggy_update.c iguana_accept.c iguana_json.c iguana_tx.c peggy.c poker.c iguana_bitmap.c iguana_msg.c iguana_unspents.c peggy_accts.c ramchain_api.c iguana_blocks.c iguana_peers.c iguana_wallet.c peggy_consensus.c secp256k1/src/secp256k1.c |
SOURCES := SuperNET.c iguana_bundles.c iguana_stake.c iguana_interpreter.c mini-gmp.c main.c iguana_payments.c iguana_spendvectors.c iguana_sign.c iguana_txidfind.c iguana_realtime.c iguana_volatiles.c peggy_price.c SuperNET_category.c iguana_chains.c iguana_ramchain.c iguana_secp.c pangea_api.c peggy_ramkv.c SuperNET_hexmsg.c iguana_exchanges.c iguana_recv.c pangea_bets.c peggy_serdes.c SuperNET_keys.c iguana_rpc.c pangea_hand.c peggy_tx.c cards777.c iguana_init.c iguana_scripts.c pangea_json.c peggy_txind.c iguana777.c iguana_instantdex.c iguana_tradebots.c pangea_summary.c peggy_update.c iguana_accept.c iguana_json.c iguana_tx.c peggy.c poker.c iguana_bitmap.c iguana_msg.c iguana_unspents.c peggy_accts.c ramchain_api.c iguana_blocks.c iguana_peers.c iguana_wallet.c peggy_consensus.c ../basilisk/basilisk.c secp256k1/src/secp256k1.c |
@ -0,0 +1,8 @@ |
|||||
|
#./configure --enable-endomorphism --enable-module-ecdh --enable-module-schnorr --enable-module-rangeproof --enable-experimental --enable-module_recovery |
||||
|
rm ../agents/iguana *.o |
||||
|
git pull |
||||
|
cd secp256k1; ./m_unix; cd .. |
||||
|
gcc -g -Wno-deprecated -c -O2 *.c #databases/iguana_DB.c |
||||
|
gcc -g -Wno-deprecated -c main.c iguana777.c iguana_bundles.c |
||||
|
#gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lcrypto -lpthread -lm #../includes/libsecp256k1.a -lgmp |
||||
|
gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lcurl -lssl -lcrypto -lpthread -lz -lm |
@ -0,0 +1 @@ |
|||||
|
../agents/iguana "{\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"LTC\",\"active\":1,\"maxpeers\":1,\"services\":128,\"poll\":30,\"RELAY\":0,\"VALIDATE\":0}" |
@ -1 +1 @@ |
|||||
curl --url "http://127.0.0.1:7778" --data "{\"timeout\":20000,\"agent\":\"iguana\",\"method\":\"balances\",\"lastheight\":0,\"activecoin\":\"BTCD\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"]}" |
curl --url "http://127.0.0.1:7778" --data "{\"timeout\":20000,\"agent\":\"basilisk\",\"method\":\"balances\",\"lastheight\":0,\"activecoin\":\"BTCD\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"]}" |
||||
|
@ -1 +1 @@ |
|||||
curl --url "http://127.0.0.1:14632" --data "{\"timeout\":25000,\"agent\":\"iguana\",\"method\":\"rawtx\",\"changeaddr\":\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\",\"addresses\":[\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\"],\"vals\":{\"coin\":\"BTC\",\"amount\":\"20000\"},\"spendscriptstr\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}" |
curl --url "http://127.0.0.1:14632" --data "{\"timeout\":25000,\"agent\":\"basilisk\",\"method\":\"rawtx\",\"changeaddr\":\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\",\"addresses\":[\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\"],\"vals\":{\"coin\":\"BTC\",\"amount\":\"20000\"},\"spendscriptstr\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}" |
||||
|
@ -0,0 +1 @@ |
|||||
|
curl --url "http://127.0.0.1:7778" --data "{\"timeout\":25000,\"agent\":\"basilisk\",\"method\":\"rawtx\",\"changeaddr\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"],\"vals\":{\"coin\":\"BTCD\",\"amount\":\"20000\"},\"spendscriptstr\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}" |
Loading…
Reference in new issue