Take expiryheight as param to createrawtransaction
This commit is contained in:
@@ -77,6 +77,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "createrawtransaction", 0 },
|
{ "createrawtransaction", 0 },
|
||||||
{ "createrawtransaction", 1 },
|
{ "createrawtransaction", 1 },
|
||||||
{ "createrawtransaction", 2 },
|
{ "createrawtransaction", 2 },
|
||||||
|
{ "createrawtransaction", 3 },
|
||||||
{ "signrawtransaction", 1 },
|
{ "signrawtransaction", 1 },
|
||||||
{ "signrawtransaction", 2 },
|
{ "signrawtransaction", 2 },
|
||||||
{ "sendrawtransaction", 1 },
|
{ "sendrawtransaction", 1 },
|
||||||
@@ -189,4 +190,3 @@ UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::s
|
|||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
UniValue createrawtransaction(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(
|
throw runtime_error(
|
||||||
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...} ( locktime )\n"
|
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...} ( locktime )\n"
|
||||||
"\nCreate a transaction spending the given inputs and sending to the given addresses.\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"
|
||||||
" }\n"
|
" }\n"
|
||||||
"3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\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"
|
"\nResult:\n"
|
||||||
"\"transaction\" (string) hex string of the transaction\n"
|
"\"transaction\" (string) hex string of the transaction\n"
|
||||||
|
|
||||||
@@ -443,7 +444,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
|
|||||||
);
|
);
|
||||||
|
|
||||||
LOCK(cs_main);
|
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())
|
if (params[0].isNull() || params[1].isNull())
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null");
|
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;
|
int nextBlockHeight = chainActive.Height() + 1;
|
||||||
CMutableTransaction rawTx = CreateNewContextualCMutableTransaction(
|
CMutableTransaction rawTx = CreateNewContextualCMutableTransaction(
|
||||||
Params().GetConsensus(), nextBlockHeight);
|
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()) {
|
if (params.size() > 2 && !params[2].isNull()) {
|
||||||
int64_t nLockTime = params[2].get_int64();
|
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");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, locktime out of range");
|
||||||
rawTx.nLockTime = nLockTime;
|
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++) {
|
for (size_t idx = 0; idx < inputs.size(); idx++) {
|
||||||
const UniValue& input = inputs[idx];
|
const UniValue& input = inputs[idx];
|
||||||
|
|||||||
Reference in New Issue
Block a user