Update zmigrate

This commit is contained in:
jl777
2018-12-16 04:59:04 -11:00
parent b2ac875f2e
commit c1e694dd80

View File

@@ -670,6 +670,7 @@ int64_t find_onetime_amount(char *coinstr,char *coinaddr)
coinaddr[0] = 0; coinaddr[0] = 0;
if ( (array= get_listunspent(coinstr,"")) != 0 ) if ( (array= get_listunspent(coinstr,"")) != 0 )
{ {
//printf("got listunspent.(%s)\n",jprint(array,0));
if ( (n= cJSON_GetArraySize(array)) > 0 ) if ( (n= cJSON_GetArraySize(array)) > 0 )
{ {
for (i=0; i<n; i++) for (i=0; i<n; i++)
@@ -734,6 +735,7 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char *
cJSON *retjson; char *retstr,params[1024],addr[128]; cJSON *retjson; char *retstr,params[1024],addr[128];
sprintf(params,"'[{\"address\":\"%s\",\"amount\":%.8f}]'",destaddr,dstr(amount)); sprintf(params,"'[{\"address\":\"%s\",\"amount\":%.8f}]'",destaddr,dstr(amount));
sprintf(addr,"\"%s\"",srcaddr); sprintf(addr,"\"%s\"",srcaddr);
printf("z_sendmany from.(%s) -> %s\n",srcaddr,params);
if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 ) if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 )
{ {
printf("unexpected json z_sendmany.(%s)\n",jprint(retjson,0)); printf("unexpected json z_sendmany.(%s)\n",jprint(retjson,0));
@@ -906,7 +908,7 @@ int32_t main(int32_t argc,char **argv)
zsaddr = clonestr(argv[2]); zsaddr = clonestr(argv[2]);
printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr); printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr);
uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee;
stdamount = 10000 * SATOSHIDEN; //stdamount = 500 * SATOSHIDEN;
txfee = 10000; txfee = 10000;
again: again:
printf("start processing zmigrate\n"); printf("start processing zmigrate\n");
@@ -916,7 +918,7 @@ again:
{ {
if ( have_pending_opid(coinstr,0) != 0 ) if ( have_pending_opid(coinstr,0) != 0 )
{ {
sleep(60); sleep(10);
continue; continue;
} }
if ( (amount= find_onetime_amount(coinstr,coinaddr)) > txfee ) if ( (amount= find_onetime_amount(coinstr,coinaddr)) > txfee )
@@ -930,14 +932,33 @@ again:
if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee ) if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee )
{ {
// generate taddr, send max of 10000.0001 // generate taddr, send max of 10000.0001
if ( amount > stdamount+txfee ) static int64_t lastamount,lastamount2,lastamount3,lastamount4,refamount = 5000 * SATOSHIDEN;
amount = stdamount + txfee; stdamount = refamount;
if ( amount == lastamount && amount == lastamount2 )
{
stdamount /= 10;
if ( amount == lastamount3 && amount == lastamount4 )
stdamount /= 10;
}
if ( stdamount < COIN )
{
stdamount = COIN;
refamount = COIN * 50;
}
if ( stdamount < refamount )
refamount = stdamount;
lastamount4 = lastamount3;
lastamount3 = lastamount2;
lastamount2 = lastamount;
lastamount = amount;
if ( amount > stdamount+2*txfee )
amount = stdamount + 2*txfee;
if ( getnewaddress(coinaddr,coinstr,"") == 0 ) if ( getnewaddress(coinaddr,coinstr,"") == 0 )
{ {
z_sendmany(opidstr,coinstr,"",zcaddr,coinaddr,amount-txfee); z_sendmany(opidstr,coinstr,"",zcaddr,coinaddr,amount-txfee);
lastopid = (uint32_t)time(NULL); lastopid = (uint32_t)time(NULL);
} else printf("couldnt getnewaddress!\n"); } else printf("couldnt getnewaddress!\n");
sleep(30); sleep(3);
continue; continue;
} }
if ( time(NULL) > lastopid+600 ) if ( time(NULL) > lastopid+600 )