Browse Source

Take expiryheight as param to createrawtransaction

pull/4/head
Jay Graber 6 years ago
committed by Simon
parent
commit
76277ad8af
  1. 2
      src/rpc/client.cpp
  2. 21
      src/rpc/rawtransaction.cpp

2
src/rpc/client.cpp

@ -77,6 +77,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "createrawtransaction", 0 },
{ "createrawtransaction", 1 },
{ "createrawtransaction", 2 },
{ "createrawtransaction", 3 },
{ "signrawtransaction", 1 },
{ "signrawtransaction", 2 },
{ "sendrawtransaction", 1 },
@ -189,4 +190,3 @@ UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::s
return params;
}

21
src/rpc/rawtransaction.cpp

@ -410,7 +410,7 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp)
UniValue createrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 3)
if (fHelp || params.size() < 2 || params.size() > 4)
throw runtime_error(
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...} ( locktime )\n"
"\nCreate a transaction spending the given inputs and sending to the given addresses.\n"
@ -434,6 +434,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
" ,...\n"
" }\n"
"3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n"
"4. expiryheight (numeric, optional, default=0) Expiry height of transaction\n"
"\nResult:\n"
"\"transaction\" (string) hex string of the transaction\n"
@ -443,7 +444,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
);
LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM), true);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM)(UniValue::VNUM), true);
if (params[0].isNull() || params[1].isNull())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null");
@ -453,12 +454,6 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
int nextBlockHeight = chainActive.Height() + 1;
CMutableTransaction rawTx = CreateNewContextualCMutableTransaction(
Params().GetConsensus(), nextBlockHeight);
if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
if (rawTx.nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD){
throw JSONRPCError(RPC_INVALID_PARAMETER, "nExpiryHeight must be less than TX_EXPIRY_HEIGHT_THRESHOLD.");
}
}
if (params.size() > 2 && !params[2].isNull()) {
int64_t nLockTime = params[2].get_int64();
@ -466,6 +461,16 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, locktime out of range");
rawTx.nLockTime = nLockTime;
}
if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
if (params.size() > 3 && !params[3].isNull()) {
int64_t nExpiryHeight = params[3].get_int64();
if (nExpiryHeight < 0 || nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, nExpiryHeight must be less than TX_EXPIRY_HEIGHT_THRESHOLD.");
}
rawTx.nExpiryHeight = nExpiryHeight;
}
}
for (size_t idx = 0; idx < inputs.size(); idx++) {
const UniValue& input = inputs[idx];

Loading…
Cancel
Save