diff --git a/src/masternodes/mn_rpc.cpp b/src/masternodes/mn_rpc.cpp index 4bc0bf426b..47bf23da06 100644 --- a/src/masternodes/mn_rpc.cpp +++ b/src/masternodes/mn_rpc.cpp @@ -89,10 +89,6 @@ signsend(const CMutableTransaction& _mtx, JSONRPCRequest const& request, CWallet } } -static UniValue fundsignsend(CMutableTransaction mtx, JSONRPCRequest const& request, CWallet* const pwallet) { - return signsend(fund(std::move(mtx), request, pwallet), request, pwallet)->GetHash().GetHex(); -} - // returns either base58/bech32 address, or hex if format is unknown std::string ScriptToString(CScript const& script) { CTxDestination dest; @@ -255,7 +251,6 @@ UniValue createmasternode(const JSONRPCRequest& request) { return signsend(rawTx, request, pwallet)->GetHash().GetHex(); } - UniValue resignmasternode(const JSONRPCRequest& request) { CWallet* const pwallet = GetWallet(request); @@ -335,7 +330,6 @@ UniValue resignmasternode(const JSONRPCRequest& request) { return signsend(rawTx, request, pwallet)->GetHash().GetHex(); } - // Here (but not a class method) just by similarity with other '..ToJSON' UniValue mnToJSON(uint256 const & nodeId, CMasternode const& node, bool verbose) { UniValue ret(UniValue::VOBJ); @@ -529,55 +523,55 @@ UniValue createtoken(const JSONRPCRequest& request) { RPCHelpMan{"createtoken", "\nCreates (and submits to local node and network) a token creation transaction with given metadata.\n" - "The first optional argument (may be empty array) is an array of specific UTXOs to spend." + + "The second optional argument (may be empty array) is an array of specific UTXOs to spend." + HelpRequiringPassphrase(pwallet) + "\n", { - {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, - "A json array of json objects", + {"metadata", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", { - {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", - { - {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, - {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - }, - }, + {"symbol", RPCArg::Type::STR, RPCArg::Optional::NO, + "Token's symbol (unique), no longer than " + + std::to_string(CToken::MAX_TOKEN_SYMBOL_LENGTH)}, + {"name", RPCArg::Type::STR, RPCArg::Optional::OMITTED, + "Token's name (optional), no longer than " + + std::to_string(CToken::MAX_TOKEN_NAME_LENGTH)}, + {"isDAT", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, + "Token's 'isDAT' property (bool, optional), default is 'False'"}, + {"decimal", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, + "Token's decimal places (optional, fixed to 8 for now, unchecked)"}, + {"limit", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, + "Token's total supply limit (optional, zero for now, unchecked)"}, + {"mintable", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, + "Token's 'Mintable' property (bool, optional), fixed to 'True' for now"}, + {"tradeable", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, + "Token's 'Tradeable' property (bool, optional), fixed to 'True' for now"}, + {"collateralAddress", RPCArg::Type::STR, RPCArg::Optional::NO, + "Any valid destination for keeping collateral amount - used as token's owner auth"}, }, - }, - {"metadata", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + }, + {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, + "A json array of json objects", { - {"symbol", RPCArg::Type::STR, RPCArg::Optional::NO, - "Token's symbol (unique), no longer than " + - std::to_string(CToken::MAX_TOKEN_SYMBOL_LENGTH)}, - {"name", RPCArg::Type::STR, RPCArg::Optional::OMITTED, - "Token's name (optional), no longer than " + - std::to_string(CToken::MAX_TOKEN_NAME_LENGTH)}, - {"isDAT", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, - "Token's 'isDAT' property (bool, optional), default is 'False'"}, - {"decimal", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, - "Token's decimal places (optional, fixed to 8 for now, unchecked)"}, - {"limit", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, - "Token's total supply limit (optional, zero for now, unchecked)"}, - {"mintable", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, - "Token's 'Mintable' property (bool, optional), fixed to 'True' for now"}, - {"tradeable", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, - "Token's 'Tradeable' property (bool, optional), fixed to 'True' for now"}, - {"collateralAddress", RPCArg::Type::STR, RPCArg::Optional::NO, - "Any valid destination for keeping collateral amount - used as token's owner auth"}, + {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + { + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, + {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, + }, + }, }, - }, + }, }, RPCResult{ "\"hash\" (string) The hex-encoded hash of broadcasted transaction\n" }, RPCExamples{ - HelpExampleCli("createtoken", "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\" " - "\"{\\\"symbol\\\":\\\"MyToken\\\"," - "\\\"collateralAddress\\\":\\\"address\\\"" - "}\"") - + HelpExampleRpc("createtoken", "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\" " - "\"{\\\"symbol\\\":\\\"MyToken\\\"," - "\\\"collateralAddress\\\":\\\"address\\\"" - "}\"") + HelpExampleCli("createtoken", "\"{\\\"symbol\\\":\\\"MyToken\\\"," + "\\\"collateralAddress\\\":\\\"address\\\"}\"") + + HelpExampleCli("createtoken", "\"{\\\"symbol\\\":\\\"MyToken\\\"," + "\\\"collateralAddress\\\":\\\"address\\\"}\" " + "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\"") + + HelpExampleRpc("createtoken", "\"{\\\"symbol\\\":\\\"MyToken\\\"," + "\\\"collateralAddress\\\":\\\"address\\\"}\" " + "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\"") }, }.Check(request); @@ -586,13 +580,19 @@ UniValue createtoken(const JSONRPCRequest& request) { } pwallet->BlockUntilSyncedToCurrentChain(); - RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VOBJ}, true); - if (request.params[0].isNull() || request.params[1].isNull()) { + RPCTypeCheck(request.params, {UniValue::VOBJ, UniValue::VARR}, true); + if (request.params[0].isNull()) { throw JSONRPCError(RPC_INVALID_PARAMETER, - "Invalid parameters, arguments 1 and 2 must be non-null, and argument 2 expected as object at least with " - "{\"symbol\",\"collateralDest\"}"); + "Invalid parameters, arguments 1 must be non-null and expected as object at least with " + "{\"symbol\",\"collateralAddress\"}"); + } + + const UniValue metaObj = request.params[0].get_obj(); + UniValue txInputs = request.params[1]; + if (txInputs.isNull()) + { + txInputs.setArray(); } - UniValue metaObj = request.params[1].get_obj(); std::string collateralAddress = metaObj["collateralAddress"].getValStr(); CTxDestination collateralDest = DecodeDestination(collateralAddress); @@ -635,7 +635,7 @@ UniValue createtoken(const JSONRPCRequest& request) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid destination"); } try { - rawTx.vin = GetAuthInputs(pwallet, destination, request.params[0].get_array()); + rawTx.vin = GetAuthInputs(pwallet, destination, txInputs.get_array()); } catch (const UniValue& objError) {} } @@ -644,7 +644,7 @@ UniValue createtoken(const JSONRPCRequest& request) { throw JSONRPCError(RPC_INVALID_REQUEST, "Incorrect Authorization"); } else - rawTx.vin = GetInputs(request.params[0].get_array()); + rawTx.vin = GetInputs(txInputs.get_array()); rawTx.vout.push_back(CTxOut(GetTokenCreationFee(height), scriptMeta)); rawTx.vout.push_back(CTxOut(GetTokenCollateralAmount(), GetScriptForDestination(collateralDest))); @@ -669,40 +669,46 @@ UniValue destroytoken(const JSONRPCRequest& request) { RPCHelpMan{"destroytoken", "\nCreates (and submits to local node and network) a transaction destroying your token. Collateral will be unlocked.\n" - "The first optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO's must belong to the token's owner (collateral) address" + + "The second optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO's must belong to the token's owner (collateral) address" + HelpRequiringPassphrase(pwallet) + "\n", { - {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, + {"token", RPCArg::Type::STR, RPCArg::Optional::NO, "The tokens's symbol, id or creation tx"}, + {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "A json array of json objects. Provide it if you want to spent specific UTXOs", { - {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", - { - {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, - {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - }, + {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + { + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, + {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, }, + }, }, - }, - {"token", RPCArg::Type::STR, RPCArg::Optional::NO, "The tokens's symbol, id or creation tx"}, + }, }, RPCResult{ "\"hash\" (string) The hex-encoded hash of broadcasted transaction\n" }, RPCExamples{ - HelpExampleCli("destroytoken", "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\" \"symbol\"") - + HelpExampleRpc("destroytoken", "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\" \"symbol\"") + HelpExampleCli("destroytoken", "\"symbol\"") + + HelpExampleCli("destroytoken", "\"symbol\" \"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\"") + + HelpExampleRpc("destroytoken", "\"symbol\" \"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\"") }, }.Check(request); if (pwallet->chain().isInitialBlockDownload()) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, - "Cannot resign Masternode while still in Initial Block Download"); + "Cannot destroy token while still in Initial Block Download"); } pwallet->BlockUntilSyncedToCurrentChain(); - RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VSTR}, true); + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR}, true); - std::string const tokenStr = trim_ws(request.params[1].getValStr()); + std::string const tokenStr = trim_ws(request.params[0].getValStr()); + UniValue txInputs = request.params[1]; + if (txInputs.isNull()) + { + txInputs.setArray(); + } CTxDestination ownerDest; uint256 creationTx{}; { @@ -727,7 +733,7 @@ UniValue destroytoken(const JSONRPCRequest& request) { CMutableTransaction rawTx; - rawTx.vin = GetAuthInputs(pwallet, ownerDest, request.params[0].get_array()); + rawTx.vin = GetAuthInputs(pwallet, ownerDest, txInputs.get_array()); CDataStream metadata(DfTxMarker, SER_NETWORK, PROTOCOL_VERSION); metadata << static_cast(CustomTxType::DestroyToken) @@ -758,50 +764,57 @@ UniValue updatetoken(const JSONRPCRequest& request) { RPCHelpMan{"updatetoken", "\nCreates (and submits to local node and network) a transaction of token promotion to isDAT or demotion from isDAT. Collateral will be unlocked.\n" - "The first optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO's must belong to the token's owner (collateral) address" + + "The second optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO's must belong to the token's owner (collateral) address" + HelpRequiringPassphrase(pwallet) + "\n", { - {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, + {"metadata", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + { + {"token", RPCArg::Type::STR, RPCArg::Optional::NO, "The tokens's symbol, id or creation tx"}, + {"isDAT", RPCArg::Type::BOOL, RPCArg::Optional::NO, "Token's 'isDAT' new property (bool)"}, + }, + }, + {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "A json array of json objects. Provide it if you want to spent specific UTXOs", { - {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", - { - {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, - {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - }, + {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + { + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, + {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, }, + }, }, - }, - {"metadata", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", - { - {"token", RPCArg::Type::STR, RPCArg::Optional::NO, "The tokens's symbol, id or creation tx"}, - {"isDAT", RPCArg::Type::BOOL, RPCArg::Optional::NO, "Token's 'isDAT' new property (bool)"}, }, - }, - }, RPCResult{ "\"hash\" (string) The hex-encoded hash of broadcasted transaction\n" }, RPCExamples{ - HelpExampleCli("updatetoken", "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\" '{\"token\":\"DFI\"," - "\"isDAT\":true," - "}'") - + HelpExampleRpc("updatetoken", "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\" '{\"token\":\"DFI\"," - "\"isDAT\":true," - "}'") + HelpExampleCli("updatetoken", "\"{\\\"token\\\":\\\"DFI\\\", \\\"isDAT\\\":true}\" " + "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\"") + + HelpExampleRpc("updatetoken", "\"{\\\"token\\\":\\\"DFI\\\", \\\"isDAT\\\":true}\" " + "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\"") }, }.Check(request); if (pwallet->chain().isInitialBlockDownload()) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, - "Cannot resign Masternode while still in Initial Block Download"); + "Cannot update token while still in Initial Block Download"); } pwallet->BlockUntilSyncedToCurrentChain(); - RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VOBJ}, true); + RPCTypeCheck(request.params, {UniValue::VOBJ, UniValue::VARR}, true); + if (request.params[0].isNull()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, + "Invalid parameters, arguments 1 must be non-null and expected as object like " + "{\"token\":\"Symbol\", \"isDAT\":true}"); + } - UniValue metaObj = request.params[1].get_obj(); + UniValue metaObj = request.params[0].get_obj(); + UniValue txInputs = request.params[1]; + if (txInputs.isNull()) + { + txInputs.setArray(); + } std::string const tokenStr = trim_ws(metaObj["token"].getValStr()); CTxDestination ownerDest; @@ -832,7 +845,7 @@ UniValue updatetoken(const JSONRPCRequest& request) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid destination"); } try { - rawTx.vin = GetAuthInputs(pwallet, destination, request.params[0].get_array()); + rawTx.vin = GetAuthInputs(pwallet, destination, txInputs.get_array()); } catch (const UniValue& objError) {} } @@ -991,42 +1004,47 @@ UniValue minttokens(const JSONRPCRequest& request) { RPCHelpMan{"minttokens", "\nCreates (and submits to local node and network) a transaction minting your token (for accounts and/or UTXOs). \n" - "The first optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO's must belong to the token's owner (collateral) address" + + "The second optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO's must belong to the token's owner (collateral) address" + HelpRequiringPassphrase(pwallet) + "\n", { - {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, + {"amounts", RPCArg::Type::STR, RPCArg::Optional::NO, + "Amount in amount@token format." + }, + {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "A json array of json objects. Provide it if you want to spent specific UTXOs", { - {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", - { - {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, - {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - }, + {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + { + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, + {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, }, + }, }, - }, - {"amounts", RPCArg::Type::STR, RPCArg::Optional::NO, - "Amount in amount@token format. " - "If multiple tokens are to be minted, specify an array [\"amount1@t1\", \"amount2@t2\"]" - }, + }, }, RPCResult{ "\"hash\" (string) The hex-encoded hash of broadcasted transaction\n" }, RPCExamples{ - HelpExampleCli("minttokens", - "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\" \"symbol\"") /// @todo tokens: modify - + HelpExampleRpc("minttokens", "\"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\" \"symbol\"") + HelpExampleCli("minttokens", "\"10@symbol\"") + + HelpExampleCli("minttokens", + "\"10@symbol\" \"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\"") /// @todo tokens: modify + + HelpExampleRpc("minttokens", "\"10@symbol\" \"[{\\\"txid\\\":\\\"id\\\",\\\"vout\\\":0}]\"") }, }.Check(request); if (pwallet->chain().isInitialBlockDownload()) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, - "Cannot resign Masternode while still in Initial Block Download"); + "Cannot mint tokens while still in Initial Block Download"); } pwallet->BlockUntilSyncedToCurrentChain(); - const CBalances minted = DecodeAmounts(pwallet->chain(), request.params[1], ""); + const CBalances minted = DecodeAmounts(pwallet->chain(), request.params[0], ""); + UniValue txInputs = request.params[1]; + if (txInputs.isNull()) + { + txInputs.setArray(); + } CMutableTransaction rawTx; @@ -1057,7 +1075,7 @@ UniValue minttokens(const JSONRPCRequest& request) { strprintf("Can't extract destination for token's %s collateral", tokenImpl.symbol)); } } - rawTx.vin = GetAuthInputs(pwallet, ownerDest, request.params[0].get_array()); + rawTx.vin = GetAuthInputs(pwallet, ownerDest, txInputs.get_array()); } } @@ -1220,28 +1238,28 @@ UniValue getaccount(const JSONRPCRequest& request) { RPCHelpMan{"getaccount", "\nReturns information about account.\n", { - {"owner", RPCArg::Type::STR, RPCArg::Optional::NO, + {"owner", RPCArg::Type::STR, RPCArg::Optional::NO, "Owner address in base58/bech32/hex encoding"}, - {"pagination", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + {"pagination", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", { - {"start", RPCArg::Type::STR, RPCArg::Optional::OMITTED, + {"start", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Optional first key to iterate from, in lexicographical order." "Typically it's set to last tokenID from previous request."}, - {"including_start", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, + {"including_start", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "If true, then iterate including starting position. False by default"}, - {"limit", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, + {"limit", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "Maximum number of orders to return, 100 by default"}, }, - }, - {"indexed_amounts", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, + }, + {"indexed_amounts", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Format of amounts output (default = false): (true: obj = {tokenid:amount,...}, false: array = [\"amount@tokenid\"...])"}, - }, - RPCResult{ + }, + RPCResult{ "{...} (array) Json object with order information\n" - }, - RPCExamples{ + }, + RPCExamples{ HelpExampleCli("getaccount", "owner_address") - }, + }, }.Check(request); // decode owner @@ -1303,35 +1321,34 @@ UniValue utxostoaccount(const JSONRPCRequest& request) { RPCHelpMan{"utxostoaccount", "\nCreates (and submits to local node and network) a transfer transaction from the wallet UTXOs to specfied account.\n" - "The first optional argument (may be empty array) is an array of specific UTXOs to spend." + + "The second optional argument (may be empty array) is an array of specific UTXOs to spend." + HelpRequiringPassphrase(pwallet) + "\n", { - {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, - "A json array of json objects", + {"amounts", RPCArg::Type::OBJ, RPCArg::Optional::NO, "", { - {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", - { - {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, - {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - }, - }, + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The defi address is the key, the value is amount in amount@token format. " + "If multiple tokens are to be transferred, specify an array [\"amount1@t1\", \"amount2@t2\"]"}, }, - }, - {"amounts", RPCArg::Type::OBJ, RPCArg::Optional::NO, "", + }, + {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, + "A json array of json objects", { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The defi address is the key, the value is amount in amount@token format. " - "If multiple tokens are to be transferred, specify an array [\"amount1@t1\", \"amount2@t2\"]"}, + {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + { + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, + {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, + }, + }, }, - }, + }, }, RPCResult{ "\"hash\" (string) The hex-encoded hash of broadcasted transaction\n" }, RPCExamples{ - HelpExampleCli("utxostoaccount", "[] " - "'{\"address1\":\"1.0@DFI\"," - "\"address2\":[\"2.0@BTC\", \"3.0@ETH\"]" - "}'") + HelpExampleCli("utxostoaccount", "\"{\\\"address1\\\":\\\"1.0@DFI\\\"," + "\\\"address2\\\":[\\\"2.0@BTC\\\", \\\"3.0@ETH\\\"]" + "}\" \"[]\"") }, }.Check(request); @@ -1339,11 +1356,11 @@ UniValue utxostoaccount(const JSONRPCRequest& request) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Cannot create transactions while still in Initial Block Download"); } - RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VOBJ}, false); + RPCTypeCheck(request.params, {UniValue::VOBJ, UniValue::VARR}, false); // decode recipients CUtxosToAccountMessage msg{}; - msg.to = DecodeRecipients(pwallet->chain(), request.params[1].get_obj()); + msg.to = DecodeRecipients(pwallet->chain(), request.params[0].get_obj()); // encode CDataStream markedMetadata(DfTxMarker, SER_NETWORK, PROTOCOL_VERSION); @@ -1393,31 +1410,32 @@ UniValue accounttoaccount(const JSONRPCRequest& request) { "The first optional argument (may be empty array) is an array of specific UTXOs to spend." + HelpRequiringPassphrase(pwallet) + "\n", { - {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, - "A json array of json objects", + {"from", RPCArg::Type::STR, RPCArg::Optional::NO, "The defi address of sender"}, + {"to", RPCArg::Type::OBJ, RPCArg::Optional::NO, "", { - {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", - { - {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, - {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - }, - }, + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The defi address is the key, the value is amount in amount@token format. " + "If multiple tokens are to be transferred, specify an array [\"amount1@t1\", \"amount2@t2\"]"}, }, - }, - {"from", RPCArg::Type::STR, RPCArg::Optional::NO, "The defi address of sender"}, - {"to", RPCArg::Type::OBJ, RPCArg::Optional::NO, "", + }, + {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, + "A json array of json objects", { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The defi address is the key, the value is amount in amount@token format. " - "If multiple tokens are to be transferred, specify an array [\"amount1@t1\", \"amount2@t2\"]"}, + {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + { + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, + {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, + }, + }, }, - }, - }, - RPCResult{ + }, + }, + RPCResult{ "\"hash\" (string) The hex-encoded hash of broadcasted transaction\n" - }, - RPCExamples{ - HelpExampleCli("accounttoaccount", "[] sender_address " - "'{\"address1\":\"1.0@DFI\",\"address2\":[\"2.0@BTC\", \"3.0@ETH\"]}'") + }, + RPCExamples{ + HelpExampleCli("accounttoaccount", "sender_address " + "\"{\\\"address1\\\":\\\"1.0@DFI\\\",\\\"address2\\\":[\\\"2.0@BTC\\\", \\\"3.0@ETH\\\"]}\" " + "[]") }, }.Check(request); @@ -1425,12 +1443,12 @@ UniValue accounttoaccount(const JSONRPCRequest& request) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Cannot create transactions while still in Initial Block Download"); } - RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VSTR, UniValue::VOBJ}, false); + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ, UniValue::VARR}, false); // decode sender and recipients CAccountToAccountMessage msg{}; - msg.from = DecodeScript(request.params[1].get_str()); - msg.to = DecodeRecipients(pwallet->chain(), request.params[2].get_obj()); + msg.from = DecodeScript(request.params[0].get_str()); + msg.to = DecodeRecipients(pwallet->chain(), request.params[1].get_obj()); if (SumAllTransfers(msg.to).balances.empty()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "zero amounts"); } @@ -1448,7 +1466,13 @@ UniValue accounttoaccount(const JSONRPCRequest& request) { if (!ExtractDestination(msg.from, ownerDest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid owner destination"); } - rawTx.vin = GetAuthInputs(pwallet, ownerDest, request.params[0].get_array()); + + UniValue txInputs = request.params[2]; + if (txInputs.isNull()) + { + txInputs.setArray(); + } + rawTx.vin = GetAuthInputs(pwallet, ownerDest, txInputs.get_array()); // fund rawTx = fund(rawTx, request, pwallet); @@ -1477,35 +1501,36 @@ UniValue accounttoutxos(const JSONRPCRequest& request) { RPCHelpMan{"accounttoutxos", "\nCreates (and submits to local node and network) a transfer transaction from the specified account to UTXOs.\n" - "The first optional argument (may be empty array) is an array of specific UTXOs to spend." + + "The third optional argument (may be empty array) is an array of specific UTXOs to spend." + HelpRequiringPassphrase(pwallet) + "\n", { - {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, - "A json array of json objects", + {"from", RPCArg::Type::STR, RPCArg::Optional::NO, "The defi address of sender"}, + {"to", RPCArg::Type::OBJ, RPCArg::Optional::NO, "", { - {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", - { - {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, - {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, - }, - }, + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, + "The defi address is the key, the value is amount in amount@token format. " + "If multiple tokens are to be transferred, specify an array [\"amount1@t1\", \"amount2@t2\"]" + }, }, - }, - {"from", RPCArg::Type::STR, RPCArg::Optional::NO, "The defi address of sender"}, - {"to", RPCArg::Type::OBJ, RPCArg::Optional::NO, "", + }, + {"inputs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, + "A json array of json objects", { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, - "The defi address is the key, the value is amount in amount@token format. " - "If multiple tokens are to be transferred, specify an array [\"amount1@t1\", \"amount2@t2\"]"}, + {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", + { + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, + {"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"}, + }, + }, }, - } - }, - RPCResult{ + }, + }, + RPCResult{ "\"hash\" (string) The hex-encoded hash of broadcasted transaction\n" - }, + }, RPCExamples{ - HelpExampleCli("accounttoutxos", "[] sender_address '{\"address1\":\"100@DFI\"}'") - + HelpExampleCli("accounttoutxos", "[] sender_address '{\"address1\":\"1.0@DFI\",\"address2\":[\"2.0@BTC\", \"3.0@ETH\"]}'") + HelpExampleCli("accounttoutxos", "sender_address \\\"{\\\"address1\\\":\\\"100@DFI\"}\\\" [] ") + + HelpExampleCli("accounttoutxos", "sender_address \"{\\\"address1\\\":\\\"1.0@DFI\\\",\\\"address2\\\":[\\\"2.0@BTC\\\", \\\"3.0@ETH\\\"]}\" []") }, }.Check(request); @@ -1513,12 +1538,12 @@ UniValue accounttoutxos(const JSONRPCRequest& request) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Cannot create transactions while still in Initial Block Download"); } - RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VSTR, UniValue::VOBJ}, false); + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ, UniValue::VARR}, false); // decode sender and recipients CAccountToUtxosMessage msg{}; - msg.from = DecodeScript(request.params[1].get_str()); - const auto to = DecodeRecipients(pwallet->chain(), request.params[2]); + msg.from = DecodeScript(request.params[0].get_str()); + const auto to = DecodeRecipients(pwallet->chain(), request.params[1]); msg.balances = SumAllTransfers(to); if (msg.balances.balances.empty()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "zero amounts"); @@ -1537,7 +1562,13 @@ UniValue accounttoutxos(const JSONRPCRequest& request) { if (!ExtractDestination(msg.from, ownerDest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid owner destination"); } - rawTx.vin = GetAuthInputs(pwallet, ownerDest, request.params[0].get_array()); + + UniValue txInputs = request.params[2]; + if (txInputs.isNull()) + { + txInputs.setArray(); + } + rawTx.vin = GetAuthInputs(pwallet, ownerDest, txInputs.get_array()); rawTx.vout.push_back(CTxOut(0, scriptMeta)); @@ -1591,17 +1622,17 @@ static const CRPCCommand commands[] = {"masternodes", "listmasternodes", &listmasternodes, {"pagination", "verbose"}}, {"masternodes", "getmasternode", &getmasternode, {"mn_id"}}, {"masternodes", "listcriminalproofs", &listcriminalproofs, {}}, - {"tokens", "createtoken", &createtoken, {"inputs", "metadata"}}, - {"tokens", "destroytoken", &destroytoken, {"inputs", "token"}}, - {"tokens", "updatetoken", &updatetoken, {"inputs", "metadata"}}, + {"tokens", "createtoken", &createtoken, {"metadata", "inputs"}}, + {"tokens", "destroytoken", &destroytoken, {"token", "inputs"}}, + {"tokens", "updatetoken", &updatetoken, {"metadata", "inputs"}}, {"tokens", "listtokens", &listtokens, {"pagination", "verbose"}}, {"tokens", "gettoken", &gettoken, {"key" }}, - {"tokens", "minttokens", &minttokens, {"inputs", "amounts"}}, + {"tokens", "minttokens", &minttokens, {"amounts", "inputs"}}, {"accounts", "listaccounts", &listaccounts, {"pagination", "verbose"}}, {"accounts", "getaccount", &getaccount, {"owner", "pagination"}}, - {"accounts", "utxostoaccount", &utxostoaccount, {"inputs", "amounts"}}, - {"accounts", "accounttoaccount", &accounttoaccount, {"inputs", "from", "to"}}, - {"accounts", "accounttoutxos", &accounttoutxos, {"inputs", "from", "to"}}, + {"accounts", "utxostoaccount", &utxostoaccount, {"amounts", "inputs"}}, + {"accounts", "accounttoaccount", &accounttoaccount, {"from", "to", "inputs"}}, + {"accounts", "accounttoutxos", &accounttoutxos, {"from", "to", "inputs"}}, }; void RegisterMasternodesRPCCommands(CRPCTable& tableRPC) { diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index e33b994ff2..8e0dca5060 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -177,25 +177,24 @@ static const CRPCConvertParam vRPCConvertParams[] = { "resignmasternode", 1, "inputs" }, { "listmasternodes", 0, "pagination" }, { "listmasternodes", 1, "verbose" }, - { "createtoken", 0, "inputs" }, - { "createtoken", 1, "metadata" }, - { "updatetoken", 0, "inputs" }, - { "updatetoken", 1, "metadata" }, - { "destroytoken", 0, "inputs" }, + { "createtoken", 0, "metadata" }, + { "createtoken", 1, "inputs"}, + { "updatetoken", 0, "metadata"}, + { "updatetoken", 1, "inputs"}, + { "destroytoken", 1, "inputs" }, { "listtokens", 0, "pagination" }, { "listtokens", 1, "verbose" }, { "gettoken", 0, "key" }, - { "minttokens", 0, "inputs" }, - { "minttokens", 1, "amounts" }, - { "utxostoaccount", 0, "inputs" }, - { "utxostoaccount", 1, "amounts" }, + { "minttokens", 1, "inputs"}, + { "utxostoaccount", 0, "amounts" }, + { "utxostoaccount", 1, "inputs" }, { "listaccounts", 0, "pagination" }, { "listaccounts", 1, "verbose" }, { "getaccount", 1, "pagination" }, - { "accounttoaccount", 0, "inputs" }, - { "accounttoaccount", 2, "to" }, - { "accounttoutxos", 0, "inputs" }, - { "accounttoutxos", 2, "to" }, + { "accounttoaccount", 1, "to" }, + { "accounttoaccount", 2, "inputs" }, + { "accounttoutxos", 1, "to" }, + { "accounttoutxos", 2, "inputs" }, { "spv_sendrawtx", 0, "rawtx" }, { "spv_createanchor", 0, "inputs" }, diff --git a/test/functional/feature_accounts_n_utxos.py b/test/functional/feature_accounts_n_utxos.py index 610ce373ac..af1ad9a3f8 100755 --- a/test/functional/feature_accounts_n_utxos.py +++ b/test/functional/feature_accounts_n_utxos.py @@ -48,41 +48,41 @@ def run_test(self): #======================== # missing from (account) try: - self.nodes[0].accounttoaccount([], self.nodes[0].getnewaddress("", "legacy"), {toGold: "100@GOLD"}) + self.nodes[0].accounttoaccount(self.nodes[0].getnewaddress("", "legacy"), {toGold: "100@GOLD"}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Can't find any UTXO" in errorString) # missing from (account exist, but no tokens) try: - self.nodes[0].accounttoaccount([], accountGold, {toGold: "100@SILVER"}) + self.nodes[0].accounttoaccount(accountGold, {toGold: "100@SILVER"}, []) except JSONRPCException as e: errorString = e.error['message'] assert("not enough balance" in errorString) # missing amount try: - self.nodes[0].accounttoaccount([], accountGold, {toGold: ""}) + self.nodes[0].accounttoaccount(accountGold, {toGold: ""}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Invalid amount" in errorString) #invalid UTXOs try: - self.nodes[0].accounttoaccount([{"": 0}], accountGold, {toGold: "100@GOLD"}) + self.nodes[0].accounttoaccount(accountGold, {toGold: "100@GOLD"}, [{"": 0}]) except JSONRPCException as e: errorString = e.error['message'] assert("JSON value is not a string as expected" in errorString) # missing (account exists, but does not belong) try: - self.nodes[0].accounttoaccount([], accountSilver, {accountGold: "100@SILVER"}) + self.nodes[0].accounttoaccount(accountSilver, {accountGold: "100@SILVER"}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Can't find any UTXO" in errorString) # transfer - self.nodes[0].accounttoaccount([], accountGold, {toGold: "100@GOLD"}) + self.nodes[0].accounttoaccount(accountGold, {toGold: "100@GOLD"}, []) self.nodes[0].generate(1) assert_equal(self.nodes[0].getaccount(accountGold, {}, True)[idGold], initialGold - 100) @@ -92,7 +92,7 @@ def run_test(self): assert_equal(self.nodes[0].getaccount(toGold, {}, True)[idGold], self.nodes[1].getaccount(toGold, {}, True)[idGold]) # transfer between nodes - self.nodes[1].accounttoaccount([], accountSilver, {toSilver: "100@SILVER"}) + self.nodes[1].accounttoaccount(accountSilver, {toSilver: "100@SILVER"}, []) self.nodes[1].generate(1) assert_equal(self.nodes[1].getaccount(accountSilver, {}, True)[idSilver], initialSilver - 100) @@ -103,7 +103,7 @@ def run_test(self): # missing (account exists, there are tokens, but not token 0) try: - self.nodes[0].accounttoaccount([], toSilver, {accountGold: "100@SILVER"}) + self.nodes[0].accounttoaccount(toSilver, {accountGold: "100@SILVER"}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Can't find any UTXO" in errorString) @@ -111,28 +111,28 @@ def run_test(self): # utxostoaccount #======================== try: - self.nodes[0].utxostoaccount([], {toGold: "100@GOLD"}) + self.nodes[0].utxostoaccount({toGold: "100@GOLD"}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Insufficient funds" in errorString) # missing amount try: - self.nodes[0].utxostoaccount([], {toGold: ""}) + self.nodes[0].utxostoaccount({toGold: ""}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Invalid amount" in errorString) #invalid UTXOs try: - self.nodes[0].utxostoaccount([{"": 0}], {accountGold: "100@DFI"}) + self.nodes[0].utxostoaccount({accountGold: "100@DFI"}, [{"": 0}]) except JSONRPCException as e: errorString = e.error['message'] assert("Invalid amount" in errorString) # transfer initialBalance = self.nodes[0].getbalances()['mine']['trusted'] - self.nodes[0].utxostoaccount([], {accountGold: "100@DFI"}) + self.nodes[0].utxostoaccount({accountGold: "100@DFI"}, []) self.nodes[0].generate(1) assert(initialBalance != self.nodes[0].getbalances()['mine']['trusted']) @@ -140,41 +140,41 @@ def run_test(self): #======================== # missing from (account) try: - self.nodes[0].accounttoutxos([], self.nodes[0].getnewaddress("", "legacy"), {toGold: "100@GOLD"}) + self.nodes[0].accounttoutxos(self.nodes[0].getnewaddress("", "legacy"), {toGold: "100@GOLD"}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Can't find any UTXO" in errorString) # missing amount try: - self.nodes[0].accounttoutxos([], accountGold, {accountGold: ""}) + self.nodes[0].accounttoutxos(accountGold, {accountGold: ""}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Invalid amount" in errorString) #invalid UTXOs try: - self.nodes[0].accounttoutxos([{"": 0}], accountGold, {accountGold: "100@GOLD"}) + self.nodes[0].accounttoutxos(accountGold, {accountGold: "100@GOLD"}, [{"": 0}]) except JSONRPCException as e: errorString = e.error['message'] assert("JSON value is not a string as expected" in errorString) # missing (account exists, but does not belong) try: - self.nodes[0].accounttoutxos([], accountSilver, {accountGold: "100@SILVER"}) + self.nodes[0].accounttoutxos(accountSilver, {accountGold: "100@SILVER"}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Can't find any UTXO" in errorString) # missing (account exists, there are tokens, but not token 0) try: - self.nodes[0].accounttoutxos([], toSilver, {accountGold: "100@SILVER"}) + self.nodes[0].accounttoutxos(toSilver, {accountGold: "100@SILVER"}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Can't find any UTXO" in errorString) # transfer - self.nodes[0].accounttoutxos([], accountGold, {accountGold: "100@GOLD"}) + self.nodes[0].accounttoutxos(accountGold, {accountGold: "100@GOLD"}, []) self.nodes[0].generate(1) assert_equal(self.nodes[0].getaccount(accountGold, {}, True)[idGold], initialGold - 200) diff --git a/test/functional/feature_tokens_basic.py b/test/functional/feature_tokens_basic.py index cb071075ca..b0cd6b9040 100755 --- a/test/functional/feature_tokens_basic.py +++ b/test/functional/feature_tokens_basic.py @@ -39,22 +39,22 @@ def run_test(self): # Fail to create: Insufficient funds (not matured coins) try: - createTokenTx = self.nodes[0].createtoken([], { + createTokenTx = self.nodes[0].createtoken({ "symbol": "GOLD", "name": "shiny gold", "collateralAddress": collateral0 - }) + }, []) except JSONRPCException as e: errorString = e.error['message'] assert("Insufficient funds" in errorString) print ("Create token 'GOLD' (128)...") self.nodes[0].generate(1) - createTokenTx = self.nodes[0].createtoken([], { + createTokenTx = self.nodes[0].createtoken({ "symbol": "GOLD", "name": "shiny gold", "collateralAddress": collateral0 - }) + }, []) # Create and sign (only) collateral spending tx spendTx = self.nodes[0].createrawtransaction([{'txid':createTokenTx, 'vout':1}],[{collateral0:9.999}]) @@ -107,7 +107,7 @@ def run_test(self): #======================== # Try to resign w/o auth (no money on auth/collateral address) try: - self.nodes[0].destroytoken([], "GOLD") + self.nodes[0].destroytoken("GOLD", []) except JSONRPCException as e: errorString = e.error['message'] assert("Can't find any UTXO's" in errorString) @@ -117,13 +117,13 @@ def run_test(self): self.nodes[0].generate(1) print ("Destroy token...") - destroyTx = self.nodes[0].destroytoken([], "GOLD") + destroyTx = self.nodes[0].destroytoken("GOLD", []) self.nodes[0].generate(1) assert_equal(self.nodes[0].listtokens()['128']['destructionTx'], destroyTx) # Try to mint destroyed token ('minting' is not the task of current test, but let's check it here) try: - self.nodes[0].minttokens([], "100@GOLD") + self.nodes[0].minttokens("100@GOLD", []) except JSONRPCException as e: errorString = e.error['message'] assert("already destroyed" in errorString) diff --git a/test/functional/feature_tokens_dat.py b/test/functional/feature_tokens_dat.py index f788dd5d07..291c8be6a5 100755 --- a/test/functional/feature_tokens_dat.py +++ b/test/functional/feature_tokens_dat.py @@ -40,12 +40,12 @@ def run_test(self): self.nodes[0].generate(1) # 1 Creating DAT token - self.nodes[0].createtoken([], { + self.nodes[0].createtoken({ "symbol": "PT", "name": "Platinum", "isDAT": True, "collateralAddress": collateral0 - }) + }, []) self.nodes[0].generate(1) self.sync_blocks([self.nodes[0], self.nodes[2]]) @@ -62,7 +62,7 @@ def run_test(self): # 2 Trying to make it regular try: - self.nodes[0].updatetoken([], {"token": "PT", "isDAT": False}) + self.nodes[0].updatetoken({"token": "PT", "isDAT": False}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Token PT is a 'stable coin'" in errorString) @@ -77,12 +77,12 @@ def run_test(self): # 3 Trying to make regular token self.nodes[0].generate(1) - createTokenTx = self.nodes[0].createtoken([], { + createTokenTx = self.nodes[0].createtoken({ "symbol": "GOLD", "name": "shiny gold", "isDAT": False, "collateralAddress": collateral0 - }) + }, []) self.nodes[0].generate(1) # Checks tokens = self.nodes[0].listtokens() @@ -94,13 +94,13 @@ def run_test(self): # 4 Trying to make it DAT not from Foundation try: - self.nodes[2].updatetoken([], {"token": "GOLD", "isDAT": True}) + self.nodes[2].updatetoken({"token": "GOLD", "isDAT": True}, []) except JSONRPCException as e: errorString = e.error['message'] assert("Incorrect Authorization" in errorString) # 5 Making token isDAT from Foundation - self.nodes[0].updatetoken([], {"token": "GOLD", "isDAT": True}) + self.nodes[0].updatetoken({"token": "GOLD", "isDAT": True}, []) self.nodes[0].generate(1) # Checks @@ -116,7 +116,7 @@ def run_test(self): assert_equal(tokens['128']["isDAT"], True) # 7 Removing DAT - self.nodes[0].updatetoken([], {"token": "GOLD", "isDAT": False}) + self.nodes[0].updatetoken({"token": "GOLD", "isDAT": False}, []) self.nodes[0].generate(1) @@ -127,12 +127,12 @@ def run_test(self): self.nodes[0].generate(1) # 8 Creating DAT token - self.nodes[0].createtoken([], { + self.nodes[0].createtoken({ "symbol": "TEST", "name": "TEST token", "isDAT": True, "collateralAddress": collateral0 - }) + }, []) self.nodes[0].generate(1) diff --git a/test/functional/feature_tokens_minting.py b/test/functional/feature_tokens_minting.py index 7e583a4aba..66eb0e96f1 100755 --- a/test/functional/feature_tokens_minting.py +++ b/test/functional/feature_tokens_minting.py @@ -30,16 +30,16 @@ def run_test(self): #======================== collateralGold = self.nodes[0].getnewaddress("", "legacy") collateralSilver = self.nodes[0].getnewaddress("", "legacy") - self.nodes[0].createtoken([], { + self.nodes[0].createtoken({ "symbol": "GOLD", "name": "shiny gold", "collateralAddress": collateralGold - }) - self.nodes[0].createtoken([], { + }, []) + self.nodes[0].createtoken({ "symbol": "SILVER", "name": "just silver", "collateralAddress": collateralSilver - }) + }, []) self.nodes[0].generate(1) # At this point, tokens was created @@ -63,13 +63,13 @@ def run_test(self): # print(self.nodes[0].listunspent()) alienMintAddr = self.nodes[1].getnewaddress("", "legacy") - self.nodes[0].minttokens([], "300@GOLD") - self.nodes[0].minttokens([], "3000@SILVER") + self.nodes[0].minttokens("300@GOLD", []) + self.nodes[0].minttokens("3000@SILVER", []) self.nodes[0].generate(1) self.sync_blocks() - self.nodes[0].accounttoutxos([], collateralGold, { self.nodes[0].getnewaddress("", "legacy"): "100@GOLD", alienMintAddr: "200@GOLD"}) - self.nodes[0].accounttoutxos([], collateralSilver, { self.nodes[0].getnewaddress("", "legacy"): "1000@SILVER", alienMintAddr: "2000@SILVER"}) + self.nodes[0].accounttoutxos(collateralGold, { self.nodes[0].getnewaddress("", "legacy"): "100@GOLD", alienMintAddr: "200@GOLD"}, []) + self.nodes[0].accounttoutxos(collateralSilver, { self.nodes[0].getnewaddress("", "legacy"): "1000@SILVER", alienMintAddr: "2000@SILVER"}, []) self.nodes[0].generate(1) self.sync_blocks() diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 8e6f7b7356..57668ca924 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -325,24 +325,24 @@ def setup_tokens(self): self.nodes[0].generate(100) self.sync_all() - self.nodes[0].createtoken([], { + self.nodes[0].createtoken({ "symbol": "GOLD", "name": "shiny gold", "collateralAddress": self.nodes[0].get_genesis_keys().ownerAuthAddress # collateralGold - }) - self.nodes[1].createtoken([], { + }, []) + self.nodes[1].createtoken({ "symbol": "SILVER", "name": "just silver", "collateralAddress": self.nodes[1].get_genesis_keys().ownerAuthAddress # collateralSilver - }) + }, []) self.sync_mempools() self.nodes[0].generate(1) # At this point, tokens was created tokens = self.nodes[0].listtokens() assert_equal(len(tokens), 3) - self.nodes[0].minttokens([], "1000@GOLD") - self.nodes[1].minttokens([], "2000@SILVER") + self.nodes[0].minttokens("1000@GOLD", []) + self.nodes[1].minttokens("2000@SILVER", []) self.sync_mempools() self.nodes[0].generate(1)