Print batontxid

This commit is contained in:
jl777
2019-01-14 23:25:17 -11:00
parent cc839d6f77
commit 9755dbc647
3 changed files with 24 additions and 7 deletions

View File

@@ -26,6 +26,7 @@
uint64_t komodo_block_prg(uint32_t nHeight);
int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid);
int32_t MarmaraGetbatontxid(uint256 &batontxid,uint256 txid);
UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...]
UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid);

View File

@@ -178,13 +178,26 @@ int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid)
return(0);
else if ( funcid == 'R' )
{
createtxid = txid;
if ( createtxid == zeroid )
createtxid = txid;
return(0);
}
}
return(-1);
}
int32_t MarmaraGetbatontxid(uint256 &batontxid,uint256 txid)
{
uint256 createtxid;
memset(&batontxid,0,sizeof(batontxid));
if ( MarmaraGetcreatetxid(createtxid,txid) == 0 )
{
return(0);
}
return(-1);
}
CScript Marmara_scriptPubKey(int32_t height,CPubKey pk)
{
CTxOut ccvout;
@@ -420,6 +433,8 @@ UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::stri
result.push_back(Pair("rawtx",rawtx));
result.push_back(Pair("funcid","R"));
result.push_back(Pair("createtxid",createtxid.GetHex()));
if ( batontxid != zeroid )
result.push_back(Pair("batontxid",batontxid.GetHex()));
result.push_back(Pair("senderpk",HexStr(senderpk)));
result.push_back(Pair("amount",ValueFromAmount(amount)));
result.push_back(Pair("matures",matures));
@@ -445,8 +460,8 @@ UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t a
errorstr = (char *)"for now, only MARMARA loops are supported";
else if ( amount < txfee )
errorstr = (char *)"amount must be for more than txfee";
else if ( matures <= chainActive.LastTip()->GetHeight() )
errorstr = (char *)"it must mature in the future";
//else if ( matures <= chainActive.LastTip()->GetHeight() )
// errorstr = (char *)"it must mature in the future";
if ( errorstr == 0 )
{
mtx.vin.push_back(CTxIn(approvaltxid,0,CScript()));
@@ -544,7 +559,7 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_
for (i=0; i<matches; i++)
a.push_back(issuances[i].GetHex());
result.push_back(Pair("issuances",a));
result.push_back(Pair("totalamount",totalamount));
result.push_back(Pair("totalamount",ValueFromAmount(totalamount)));
}
return(result);
}

View File

@@ -5602,9 +5602,9 @@ UniValue marmara_issue(const UniValue& params, bool fHelp)
UniValue marmara_transfer(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); uint256 approvaltxid,batontxid; std::vector<uint8_t> receiverpub; int64_t amount; int32_t matures; std::string currency;
if ( fHelp || params.size() != 6 )
if ( fHelp || params.size() != 5 )
{
// marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e bf6b4d42aa3ce974c853d73b06c78597dd3b5fb493d5d0d944f72c2017f561ad
// marmaratransfer 028076d42eb20efc10007fafb5ca66a2052523c0d2221e607adf958d1a332159f6 7.5 MARMARA 3903 748a4c80e6f6b725340fb0f52738f38a11c422d59b3034c8366b3d7b33c99a1e
throw runtime_error("marmaratransfer receiverpk amount currency matures approvaltxid\n");
}
if ( ensure_CCrequirements() < 0 )
@@ -5619,7 +5619,8 @@ UniValue marmara_transfer(const UniValue& params, bool fHelp)
currency = params[2].get_str();
matures = atol(params[3].get_str().c_str());
approvaltxid = Parseuint256((char *)params[4].get_str().c_str());
batontxid = Parseuint256((char *)params[5].get_str().c_str());
if ( MarmaraGetbatontxid(batontxid,approvaltxid) < 0 )
throw runtime_error("couldnt find batontxid\n");
return(MarmaraIssue(0,'T',pubkey2pk(receiverpub),amount,currency,matures,approvaltxid,batontxid));
}