Browse Source

Test

etomic
jl777 7 years ago
parent
commit
0d0bd3b99e
  1. 5
      iguana/exchanges/LP_coins.c
  2. 2
      iguana/exchanges/LP_rpc.c
  3. 27
      iguana/exchanges/LP_swap.c
  4. 8
      iguana/exchanges/LP_transaction.c

5
iguana/exchanges/LP_coins.c

@ -290,7 +290,7 @@ struct iguana_info *LP_coinfind(char *symbol)
if ( (busport= LP_busport(port)) == 0 )
return(0);
isPoS = 0;
txfee = 10000;
txfee = LP_MIN_TXFEE;
estimatedrate = 20;
pubtype = 60;
p2shtype = 85;
@ -332,8 +332,7 @@ struct iguana_info *LP_coincreate(cJSON *item)
if ( (symbol= jstr(item,"coin")) != 0 && symbol[0] != 0 && strlen(symbol) < 16 && LP_coinfind(symbol) == 0 && (port= juint(item,"rpcport")) != 0 )
{
isPoS = jint(item,"isPoS");
if ( (txfee= j64bits(item,"txfee")) == 0 )
txfee = 10000;
txfee = j64bits(item,"txfee");
if ( (estimatedrate= jdouble(item,"estimatedrate")) == 0. )
estimatedrate = 20;
pubtype = juint(item,"pubtype");

2
iguana/exchanges/LP_rpc.c

@ -349,7 +349,7 @@ uint64_t LP_txfee(char *symbol)
{
uint64_t txfee = 0;
if ( strcmp(symbol,"BTC") != 0 )
txfee = 10000;
txfee = LP_MIN_TXFEE;
return(txfee);
}

27
iguana/exchanges/LP_swap.c

@ -570,11 +570,16 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba
if ( (vouts= jarray(&n,txobj,"vout")) != 0 && v < n )
{
vout = jitem(vouts,v);
if ( strcmp(rawtx->coin->symbol,swap->bobcoin.symbol) == 0 )
txfee = swap->I.Btxfee;
else if ( strcmp(rawtx->coin->symbol,swap->alicecoin.symbol) == 0 )
txfee = swap->I.Atxfee;
else txfee = 10000;
if ( strcmp("BTC",rawtx->coin->symbol) == 0 && rawtx == &swap->otherfee )
txfee = LP_MIN_TXFEE;
else
{
if ( strcmp(rawtx->coin->symbol,swap->bobcoin.symbol) == 0 )
txfee = swap->I.Btxfee;
else if ( strcmp(rawtx->coin->symbol,swap->alicecoin.symbol) == 0 )
txfee = swap->I.Atxfee;
else txfee = LP_MIN_TXFEE;
}
if ( j64bits(vout,"satoshis") >= rawtx->I.amount-txfee && (skey= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(skey,"hex")) != 0 )
{
if ( (hexlen= (int32_t)strlen(hexstr) >> 1) < sizeof(rawtx->spendscript) )
@ -899,8 +904,8 @@ void basilisk_rawtx_setparms(char *name,uint32_t quoteid,struct basilisk_rawtx *
rawtx->coin = coin;
strcpy(rawtx->I.coinstr,coin->symbol);
rawtx->I.numconfirms = numconfirms;
if ( (rawtx->I.amount= satoshis) < 10000 )
rawtx->I.amount = 10000;
if ( (rawtx->I.amount= satoshis) < LP_MIN_TXFEE )
rawtx->I.amount = LP_MIN_TXFEE;
rawtx->I.vintype = vintype; // 0 -> std, 2 -> 2of2, 3 -> spend bobpayment, 4 -> spend bobdeposit
rawtx->I.vouttype = vouttype; // 0 -> fee, 1 -> std, 2 -> 2of2, 3 -> bobpayment, 4 -> bobdeposit
if ( rawtx->I.vouttype == 0 )
@ -936,10 +941,10 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256
swap->I.callduration += optionduration;
swap->I.bobsatoshis = swap->I.req.srcamount;
swap->I.alicesatoshis = swap->I.req.destamount;
if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < 10000 )
swap->I.bobinsurance = 10000;
if ( (swap->I.aliceinsurance= (swap->I.alicesatoshis / INSTANTDEX_INSURANCEDIV)) < 10000 )
swap->I.aliceinsurance = 10000;
if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE )
swap->I.bobinsurance = LP_MIN_TXFEE;
if ( (swap->I.aliceinsurance= (swap->I.alicesatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE )
swap->I.aliceinsurance = LP_MIN_TXFEE;
strcpy(swap->I.bobstr,swap->I.req.src);
strcpy(swap->I.alicestr,swap->I.req.dest);
swap->I.started = (uint32_t)time(NULL);

8
iguana/exchanges/LP_transaction.c

@ -714,7 +714,7 @@ int32_t basilisk_rawtx_sign(char *symbol,uint8_t wiftaddr,uint8_t taddr,uint8_t
locktime = swap->bobdeposit.I.locktime + 1, sequenceid = 0;
else if ( dest == &swap->bobreclaim )
locktime = swap->bobpayment.I.locktime + 1, sequenceid = 0;
txfee = strcmp("BTC",symbol) == 0 ? 0 : 10000;
txfee = strcmp("BTC",symbol) == 0 ? 0 : LP_MIN_TXFEE;
if ( changermd160 != 0 )
{
changeaddr = _changeaddr;
@ -1302,7 +1302,7 @@ void basilisk_alicepayment(struct basilisk_swap *swap,struct iguana_info *coin,s
printf(" rmd160, ");*/
bitcoin_address(coinaddr,coin->taddr,coin->pubtype,swap->changermd160,20);
//printf("%s suppress.%d fee.%d\n",coinaddr,alicepayment->I.suppress_pubkeys,swap->myfee.I.suppress_pubkeys);
basilisk_rawtx_gen(swap->ctx,"alicepayment",swap->I.started,swap->persistent_pubkey33,0,1,alicepayment,alicepayment->I.locktime,alicepayment->spendscript,alicepayment->I.spendlen,coin->txfee,1,0,swap->persistent_privkey,swap->changermd160,coinaddr);
basilisk_rawtx_gen(swap->ctx,"alicepayment",swap->I.started,swap->persistent_pubkey33,0,1,alicepayment,alicepayment->I.locktime,alicepayment->spendscript,alicepayment->I.spendlen,strcmp(coin->symbol,"BTC") == 0 ? LP_MIN_TXFEE : coin->txfee,1,0,swap->persistent_privkey,swap->changermd160,coinaddr);
}
int32_t basilisk_alicetxs(int32_t pairsock,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
@ -1329,9 +1329,9 @@ int32_t basilisk_alicetxs(int32_t pairsock,struct basilisk_swap *swap,uint8_t *d
{
printf("generate fee\n");
bitcoin_address(coinaddr,swap->alicecoin.taddr,swap->alicecoin.pubtype,swap->changermd160,20);
if ( basilisk_rawtx_gen(swap->ctx,"myfee",swap->I.started,swap->persistent_pubkey33,swap->I.iambob,1,&swap->myfee,0,swap->myfee.spendscript,swap->myfee.I.spendlen,swap->myfee.coin->txfee,1,0,swap->persistent_privkey,swap->changermd160,coinaddr) == 0 )
if ( basilisk_rawtx_gen(swap->ctx,"myfee",swap->I.started,swap->persistent_pubkey33,swap->I.iambob,1,&swap->myfee,0,swap->myfee.spendscript,swap->myfee.I.spendlen,strcmp(swap->myfee.coin->symbol,"BTC") == 0 ? LP_MIN_TXFEE : swap->myfee.coin->txfee,1,0,swap->persistent_privkey,swap->changermd160,coinaddr) == 0 )
{
printf("rawtxsend\n");
printf("rawtxsend %s %.8f\n",swap->myfee.coin->symbol,dstr(strcmp(swap->myfee.coin->symbol,"BTC") == 0 ? LP_MIN_TXFEE : swap->myfee.coin->txfee));
swap->I.statebits |= LP_swapdata_rawtxsend(pairsock,swap,0x80,data,maxlen,&swap->myfee,0x40,0);
LP_unspents_mark(swap->I.iambob!=0?swap->bobcoin.symbol:swap->alicecoin.symbol,swap->myfee.vins);
//basilisk_txlog(swap,&swap->myfee,-1);

Loading…
Cancel
Save