Merge branch 'dev' into jl777
This commit is contained in:
@@ -78,6 +78,12 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress']:
|
for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress']:
|
||||||
assert_equal(faucet[x][0], 'R')
|
assert_equal(faucet[x][0], 'R')
|
||||||
|
|
||||||
|
result = rpc.faucetaddress(self.pubkey)
|
||||||
|
assert_success(result)
|
||||||
|
# test that additional CCaddress key is returned
|
||||||
|
for x in ['myCCaddress', 'FaucetCCaddress', 'Faucetmarker', 'myaddress', 'CCaddress']:
|
||||||
|
assert_equal(result[x][0], 'R')
|
||||||
|
|
||||||
# no funds in the faucet yet
|
# no funds in the faucet yet
|
||||||
result = rpc.faucetget()
|
result = rpc.faucetget()
|
||||||
assert_error(result)
|
assert_error(result)
|
||||||
@@ -134,12 +140,146 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress']:
|
for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress']:
|
||||||
assert_equal(dice[x][0], 'R')
|
assert_equal(dice[x][0], 'R')
|
||||||
|
|
||||||
|
dice = rpc.diceaddress(self.pubkey)
|
||||||
|
assert_equal(dice['result'], 'success')
|
||||||
|
for x in ['myCCaddress', 'DiceCCaddress', 'Dicemarker', 'myaddress', 'CCaddress']:
|
||||||
|
assert_equal(dice[x][0], 'R')
|
||||||
|
|
||||||
# no dice created yet
|
# no dice created yet
|
||||||
result = rpc.dicelist()
|
result = rpc.dicelist()
|
||||||
assert_equal(result, [])
|
assert_equal(result, [])
|
||||||
|
|
||||||
#result = rpc.dicefund("LUCKY",10000,1,10000,10,5)
|
# creating dice plan with too long name (>8 chars)
|
||||||
#assert_equal(result, [])
|
result = rpc.dicefund("THISISTOOLONG", "10000", "10", "10000", "10", "5")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating dice plan with < 100 funding
|
||||||
|
result = rpc.dicefund("LUCKY","10","1","10000","10","5")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating dice plan with 0 blocks timeout
|
||||||
|
result = rpc.dicefund("LUCKY","10","1","10000","10","0")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating dice plan
|
||||||
|
dicefundtx = rpc.dicefund("LUCKY","1000","1","800","10","5")
|
||||||
|
diceid = self.send_and_mine(dicefundtx['hex'])
|
||||||
|
|
||||||
|
# checking if it in plans list now
|
||||||
|
result = rpc.dicelist()
|
||||||
|
assert_equal(result[0], diceid)
|
||||||
|
|
||||||
|
# set dice name for futher usage
|
||||||
|
dicename = "LUCKY"
|
||||||
|
|
||||||
|
# adding zero funds to plan
|
||||||
|
result = rpc.diceaddfunds(dicename,diceid,"0")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# adding negative funds to plan
|
||||||
|
result = rpc.diceaddfunds(dicename,diceid,"-1")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# adding funds to plan
|
||||||
|
addfundstx = rpc.diceaddfunds(dicename,diceid,"1100")
|
||||||
|
result = self.send_and_mine(addfundstx['hex'])
|
||||||
|
|
||||||
|
# checking if funds added to plan
|
||||||
|
result = rpc.diceinfo(diceid)
|
||||||
|
assert_equal(result["funding"], "2100.00000000")
|
||||||
|
|
||||||
|
# not valid dice info checking
|
||||||
|
result = rpc.diceinfo("invalid")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing 0 amount bet
|
||||||
|
result = rpc.dicebet(dicename,diceid,"0","1")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing negative amount bet
|
||||||
|
result = rpc.dicebet(dicename,diceid,"-1","1")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing bet more than maxbet
|
||||||
|
result = rpc.dicebet(dicename,diceid,"900","1")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing bet with amount more than funding
|
||||||
|
result = rpc.dicebet(dicename,diceid,"3000","1")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing bet with potential won more than funding
|
||||||
|
result = rpc.dicebet(dicename,diceid,"750","9")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing 0 odds bet
|
||||||
|
result = rpc.dicebet(dicename,diceid,"1","0")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing negative odds bet
|
||||||
|
result = rpc.dicebet(dicename,diceid,"1","-1")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing bet with odds more than allowed
|
||||||
|
result = rpc.dicebet(dicename,diceid,"1","11")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing bet with not correct dice name
|
||||||
|
result = rpc.dicebet("nope",diceid,"100","1")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# placing bet with not correct dice id
|
||||||
|
result = rpc.dicebet(dicename,self.pubkey,"100","1")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# valid bet placing
|
||||||
|
placebet = rpc.dicebet(dicename,diceid,"100","1")
|
||||||
|
betid = self.send_and_mine(placebet["hex"])
|
||||||
|
assert result, "bet placed"
|
||||||
|
|
||||||
|
# check bet status
|
||||||
|
result = rpc.dicestatus(dicename,diceid,betid)
|
||||||
|
assert_success(result)
|
||||||
|
|
||||||
|
# have to make some entropy for the next test
|
||||||
|
entropytx = 0
|
||||||
|
fundingsum = 1
|
||||||
|
while entropytx < 10:
|
||||||
|
fundingsuminput = str(fundingsum)
|
||||||
|
fundinghex = rpc.diceaddfunds(dicename,diceid,fundingsuminput)
|
||||||
|
result = self.send_and_mine(fundinghex['hex'])
|
||||||
|
entropytx = entropytx + 1
|
||||||
|
fundingsum = fundingsum + 1
|
||||||
|
|
||||||
|
rpc.generate(2)
|
||||||
|
|
||||||
|
# note initial dice funding state at this point.
|
||||||
|
# TODO: track player balance somehow (hard to do because of mining and fees)
|
||||||
|
diceinfo = rpc.diceinfo(diceid)
|
||||||
|
funding = float(diceinfo['funding'])
|
||||||
|
|
||||||
|
# placing same amount bets with amount 1 and odds 1:2, checking if balance changed correct
|
||||||
|
losscounter = 0
|
||||||
|
wincounter = 0
|
||||||
|
betcounter = 0
|
||||||
|
|
||||||
|
while (betcounter < 10):
|
||||||
|
placebet = rpc.dicebet(dicename,diceid,"1","1")
|
||||||
|
betid = self.send_and_mine(placebet["hex"])
|
||||||
|
finish = rpc.dicefinish(dicename,diceid,betid)
|
||||||
|
self.send_and_mine(finish["hex"])
|
||||||
|
betresult = rpc.dicestatus(dicename,diceid,betid)
|
||||||
|
betcounter = betcounter + 1
|
||||||
|
if betresult["status"] == "loss":
|
||||||
|
losscounter = losscounter + 1
|
||||||
|
elif betresult["status"] == "win":
|
||||||
|
wincounter = wincounter + 1
|
||||||
|
|
||||||
|
# funding balance should increase if player loss, decrease if player won
|
||||||
|
fundbalanceguess = funding + losscounter - wincounter
|
||||||
|
fundinfoactual = rpc.diceinfo(diceid)
|
||||||
|
assert_equal(round(fundbalanceguess),round(float(fundinfoactual['funding'])))
|
||||||
|
|
||||||
|
|
||||||
def run_token_tests(self):
|
def run_token_tests(self):
|
||||||
rpc = self.nodes[0]
|
rpc = self.nodes[0]
|
||||||
@@ -156,8 +296,18 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
result = rpc.tokenlist()
|
result = rpc.tokenlist()
|
||||||
assert_equal(result, [])
|
assert_equal(result, [])
|
||||||
|
|
||||||
result = rpc.tokencreate("DUKE", "1987.420", "duke")
|
# trying to create token with negaive supply
|
||||||
|
result = rpc.tokencreate("NUKE", "-1987420", "no bueno supply")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating token with name more than 32 chars
|
||||||
|
result = rpc.tokencreate("NUKE123456789012345678901234567890", "1987420", "name too long")
|
||||||
|
assert_error(result)
|
||||||
|
|
||||||
|
# creating valid token
|
||||||
|
result = rpc.tokencreate("DUKE", "1987.420", "Duke's custom token")
|
||||||
assert_success(result)
|
assert_success(result)
|
||||||
|
|
||||||
tokenid = self.send_and_mine(result['hex'])
|
tokenid = self.send_and_mine(result['hex'])
|
||||||
|
|
||||||
result = rpc.tokenlist()
|
result = rpc.tokenlist()
|
||||||
@@ -197,7 +347,7 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
assert_equal(result['owner'], self.pubkey)
|
assert_equal(result['owner'], self.pubkey)
|
||||||
assert_equal(result['name'], "DUKE")
|
assert_equal(result['name'], "DUKE")
|
||||||
assert_equal(result['supply'], 198742000000)
|
assert_equal(result['supply'], 198742000000)
|
||||||
assert_equal(result['description'], "duke")
|
assert_equal(result['description'], "Duke's custom token")
|
||||||
|
|
||||||
# invalid numtokens ask
|
# invalid numtokens ask
|
||||||
result = rpc.tokenask("-1", tokenid, "1")
|
result = rpc.tokenask("-1", tokenid, "1")
|
||||||
@@ -253,25 +403,25 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
result = rpc.tokenorders()
|
result = rpc.tokenorders()
|
||||||
assert_equal(result, [])
|
assert_equal(result, [])
|
||||||
|
|
||||||
# invalid numtokens bid (have to add status to CC code!)
|
# invalid numtokens bid
|
||||||
result = rpc.tokenbid("-1", tokenid, "1")
|
result = rpc.tokenbid("-1", tokenid, "1")
|
||||||
assert_equal(result['error'], 'invalid parameter')
|
assert_error(result)
|
||||||
|
|
||||||
# invalid numtokens bid (have to add status to CC code!)
|
# invalid numtokens bid
|
||||||
result = rpc.tokenbid("0", tokenid, "1")
|
result = rpc.tokenbid("0", tokenid, "1")
|
||||||
assert_equal(result['error'], 'invalid parameter')
|
assert_error(result)
|
||||||
|
|
||||||
# invalid price bid (have to add status to CC code!)
|
# invalid price bid
|
||||||
result = rpc.tokenbid("1", tokenid, "-1")
|
result = rpc.tokenbid("1", tokenid, "-1")
|
||||||
assert_equal(result['error'], 'invalid parameter')
|
assert_error(result)
|
||||||
|
|
||||||
# invalid price bid (have to add status to CC code!)
|
# invalid price bid
|
||||||
result = rpc.tokenbid("1", tokenid, "0")
|
result = rpc.tokenbid("1", tokenid, "0")
|
||||||
assert_equal(result['error'], 'invalid parameter')
|
assert_error(result)
|
||||||
|
|
||||||
# invalid tokenid bid (have to add status to CC code!)
|
# invalid tokenid bid
|
||||||
result = rpc.tokenbid("100", "deadbeef", "1")
|
result = rpc.tokenbid("100", "deadbeef", "1")
|
||||||
assert_equal(result['error'], 'invalid parameter')
|
assert_error(result)
|
||||||
|
|
||||||
# valid bid
|
# valid bid
|
||||||
tokenbid = rpc.tokenbid("100", tokenid, "10")
|
tokenbid = rpc.tokenbid("100", tokenid, "10")
|
||||||
@@ -310,11 +460,11 @@ class CryptoConditionsTest (BitcoinTestFramework):
|
|||||||
# invalid token transfer amount (have to add status to CC code!)
|
# invalid token transfer amount (have to add status to CC code!)
|
||||||
randompubkey = "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96"
|
randompubkey = "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96"
|
||||||
result = rpc.tokentransfer(tokenid,randompubkey,"0")
|
result = rpc.tokentransfer(tokenid,randompubkey,"0")
|
||||||
assert_equal(result['error'], 'invalid parameter')
|
assert_error(result)
|
||||||
|
|
||||||
# invalid token transfer amount (have to add status to CC code!)
|
# invalid token transfer amount (have to add status to CC code!)
|
||||||
result = rpc.tokentransfer(tokenid,randompubkey,"-1")
|
result = rpc.tokentransfer(tokenid,randompubkey,"-1")
|
||||||
assert_equal(result['error'], 'invalid parameter')
|
assert_error(result)
|
||||||
|
|
||||||
# valid token transfer
|
# valid token transfer
|
||||||
sendtokens = rpc.tokentransfer(tokenid,randompubkey,"1")
|
sendtokens = rpc.tokentransfer(tokenid,randompubkey,"1")
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ std::string CCerror;
|
|||||||
// Private method:
|
// Private method:
|
||||||
UniValue z_getoperationstatus_IMPL(const UniValue&, bool);
|
UniValue z_getoperationstatus_IMPL(const UniValue&, bool);
|
||||||
|
|
||||||
|
#define PLAN_NAME_MAX 8
|
||||||
|
#define VALID_PLAN_NAME(x) (strlen(x) <= PLAN_NAME_MAX)
|
||||||
|
|
||||||
std::string HelpRequiringPassphrase()
|
std::string HelpRequiringPassphrase()
|
||||||
{
|
{
|
||||||
return pwalletMain && pwalletMain->IsCrypted()
|
return pwalletMain && pwalletMain->IsCrypted()
|
||||||
@@ -5234,6 +5237,12 @@ UniValue dicefund(const UniValue& params, bool fHelp)
|
|||||||
maxbet = atof(params[3].get_str().c_str()) * COIN;
|
maxbet = atof(params[3].get_str().c_str()) * COIN;
|
||||||
maxodds = atol(params[4].get_str().c_str());
|
maxodds = atol(params[4].get_str().c_str());
|
||||||
timeoutblocks = atol(params[5].get_str().c_str());
|
timeoutblocks = atol(params[5].get_str().c_str());
|
||||||
|
|
||||||
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
|
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
hex = DiceCreateFunding(0,name,funds,minbet,maxbet,maxodds,timeoutblocks);
|
hex = DiceCreateFunding(0,name,funds,minbet,maxbet,maxodds,timeoutblocks);
|
||||||
if (CCerror != "") {
|
if (CCerror != "") {
|
||||||
ERR_RESULT(CCerror);
|
ERR_RESULT(CCerror);
|
||||||
@@ -5258,6 +5267,10 @@ UniValue diceaddfunds(const UniValue& params, bool fHelp)
|
|||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
amount = atof(params[2].get_str().c_str()) * COIN;
|
amount = atof(params[2].get_str().c_str()) * COIN;
|
||||||
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
|
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
if ( amount > 0 ) {
|
if ( amount > 0 ) {
|
||||||
hex = DiceAddfunding(0,name,fundingtxid,amount);
|
hex = DiceAddfunding(0,name,fundingtxid,amount);
|
||||||
if (CCerror != "") {
|
if (CCerror != "") {
|
||||||
@@ -5283,6 +5296,11 @@ UniValue dicebet(const UniValue& params, bool fHelp)
|
|||||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
amount = atof(params[2].get_str().c_str()) * COIN;
|
amount = atof(params[2].get_str().c_str()) * COIN;
|
||||||
odds = atol(params[3].get_str().c_str());
|
odds = atol(params[3].get_str().c_str());
|
||||||
|
|
||||||
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
|
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
if (amount > 0 && odds > 0) {
|
if (amount > 0 && odds > 0) {
|
||||||
hex = DiceBet(0,name,fundingtxid,amount,odds);
|
hex = DiceBet(0,name,fundingtxid,amount,odds);
|
||||||
if ( hex.size() > 0 )
|
if ( hex.size() > 0 )
|
||||||
@@ -5306,6 +5324,10 @@ UniValue dicefinish(const UniValue& params, bool fHelp)
|
|||||||
const CKeyStore& keystore = *pwalletMain;
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
|
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
bettxid = Parseuint256((char *)params[2].get_str().c_str());
|
bettxid = Parseuint256((char *)params[2].get_str().c_str());
|
||||||
hex = DiceBetFinish(&r,0,name,fundingtxid,bettxid,1);
|
hex = DiceBetFinish(&r,0,name,fundingtxid,bettxid,1);
|
||||||
@@ -5330,6 +5352,10 @@ UniValue dicestatus(const UniValue& params, bool fHelp)
|
|||||||
const CKeyStore& keystore = *pwalletMain;
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = (char *)params[0].get_str().c_str();
|
name = (char *)params[0].get_str().c_str();
|
||||||
|
if (!VALID_PLAN_NAME(name)) {
|
||||||
|
ERR_RESULT(strprintf("Plan name can be at most %d ASCII characters",PLAN_NAME_MAX));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
fundingtxid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
memset(&bettxid,0,sizeof(bettxid));
|
memset(&bettxid,0,sizeof(bettxid));
|
||||||
if ( params.size() == 3 )
|
if ( params.size() == 3 )
|
||||||
@@ -5453,9 +5479,14 @@ UniValue tokencreate(const UniValue& params, bool fHelp)
|
|||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
name = params[0].get_str();
|
name = params[0].get_str();
|
||||||
supply = atof(params[1].get_str().c_str()) * COIN;
|
supply = atof(params[1].get_str().c_str()) * COIN;
|
||||||
if ( name.size() == 0 || supply <= 0 )
|
if ( name.size() == 0 || name.size() > 32)
|
||||||
{
|
{
|
||||||
result.push_back(Pair("error", "invalid parameter"));
|
ERR_RESULT("Token name must not be empty and up to 32 characters");
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
if ( supply <= 0 )
|
||||||
|
{
|
||||||
|
ERR_RESULT("Token supply must be positive");
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
if ( params.size() == 3 )
|
if ( params.size() == 3 )
|
||||||
@@ -5463,7 +5494,7 @@ UniValue tokencreate(const UniValue& params, bool fHelp)
|
|||||||
description = params[2].get_str();
|
description = params[2].get_str();
|
||||||
if ( description.size() > 4096 )
|
if ( description.size() > 4096 )
|
||||||
{
|
{
|
||||||
result.push_back(Pair("error", "token description longer than 4096"));
|
ERR_RESULT("Token description must be <= 4096 characters");
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5488,9 +5519,14 @@ UniValue tokentransfer(const UniValue& params, bool fHelp)
|
|||||||
tokenid = Parseuint256((char *)params[0].get_str().c_str());
|
tokenid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
std::vector<unsigned char> pubkey(ParseHex(params[1].get_str().c_str()));
|
std::vector<unsigned char> pubkey(ParseHex(params[1].get_str().c_str()));
|
||||||
amount = atol(params[2].get_str().c_str());
|
amount = atol(params[2].get_str().c_str());
|
||||||
if ( tokenid == zeroid || amount <= 0 )
|
if ( tokenid == zeroid )
|
||||||
{
|
{
|
||||||
result.push_back(Pair("error", "invalid parameter"));
|
ERR_RESULT("invalid tokenid");
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
if ( amount <= 0 )
|
||||||
|
{
|
||||||
|
ERR_RESULT("amount must be positive");
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
hex = AssetTransfer(0,tokenid,pubkey,amount);
|
hex = AssetTransfer(0,tokenid,pubkey,amount);
|
||||||
@@ -5519,9 +5555,19 @@ UniValue tokenbid(const UniValue& params, bool fHelp)
|
|||||||
tokenid = Parseuint256((char *)params[1].get_str().c_str());
|
tokenid = Parseuint256((char *)params[1].get_str().c_str());
|
||||||
price = atof(params[2].get_str().c_str());
|
price = atof(params[2].get_str().c_str());
|
||||||
bidamount = (price * numtokens) * COIN + 0.0000000049999;
|
bidamount = (price * numtokens) * COIN + 0.0000000049999;
|
||||||
if ( tokenid == zeroid || tokenid == zeroid || price <= 0 || bidamount <= 0 )
|
if ( price <= 0 )
|
||||||
{
|
{
|
||||||
result.push_back(Pair("error", "invalid parameter"));
|
ERR_RESULT("price must be positive");
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
if ( tokenid == zeroid )
|
||||||
|
{
|
||||||
|
ERR_RESULT("invalid tokenid");
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
if ( bidamount <= 0 )
|
||||||
|
{
|
||||||
|
ERR_RESULT("bid amount must be positive");
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
hex = CreateBuyOffer(0,bidamount,tokenid,numtokens);
|
hex = CreateBuyOffer(0,bidamount,tokenid,numtokens);
|
||||||
@@ -5530,7 +5576,7 @@ UniValue tokenbid(const UniValue& params, bool fHelp)
|
|||||||
{
|
{
|
||||||
result.push_back(Pair("result", "success"));
|
result.push_back(Pair("result", "success"));
|
||||||
result.push_back(Pair("hex", hex));
|
result.push_back(Pair("hex", hex));
|
||||||
} else result.push_back(Pair("error", "couldnt create bid"));
|
} else ERR_RESULT("couldnt create bid");
|
||||||
} else {
|
} else {
|
||||||
ERR_RESULT("price and numtokens must be positive");
|
ERR_RESULT("price and numtokens must be positive");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user