52 const UniValue& oldVin = entry[
"vin"];
54 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
72 entry.
pushKV(
"vin", newVin);
75 const UniValue& oldVout = entry[
"vout"];
77 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
93 entry.
pushKV(
"vout", newVout);
107 entry.
pushKV(
"height", -1);
108 entry.
pushKV(
"confirmations", 0);
117 throw std::runtime_error(
118 "getrawtransaction \"txid\" ( verbose )\n" 120 "\nNOTE: By default this function only works for mempool transactions. If the -txindex option is\n" 121 "enabled, it also works for blockchain transactions.\n" 122 "DEPRECATED: for now, it also works for transactions with unspent outputs.\n" 124 "\nReturn the raw transaction data.\n" 125 "\nIf verbose is 'true', returns an Object with information about 'txid'.\n" 126 "If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.\n" 129 "1. \"txid\" (string, required) The transaction id\n" 130 "2. verbose (bool, optional, default=false) If false, return a string, otherwise return a json object\n" 132 "\nResult (if verbose is not set or set to false):\n" 133 "\"data\" (string) The serialized, hex-encoded data for 'txid'\n" 135 "\nResult (if verbose is set to true):\n" 137 " \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n" 138 " \"txid\" : \"id\", (string) The transaction id (same as provided)\n" 139 " \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n" 140 " \"size\" : n, (numeric) The serialized transaction size\n" 141 " \"vsize\" : n, (numeric) The virtual transaction size (differs from size for witness transactions)\n" 142 " \"version\" : n, (numeric) The version\n" 143 " \"locktime\" : ttt, (numeric) The lock time\n" 144 " \"vin\" : [ (array of json objects)\n" 146 " \"txid\": \"id\", (string) The transaction id\n" 147 " \"vout\": n, (numeric) \n" 148 " \"scriptSig\": { (json object) The script\n" 149 " \"asm\": \"asm\", (string) asm\n" 150 " \"hex\": \"hex\" (string) hex\n" 152 " \"sequence\": n (numeric) The script sequence number\n" 153 " \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n" 157 " \"vout\" : [ (array of json objects)\n" 159 " \"value\" : x.xxx, (numeric) The value in " +
CURRENCY_UNIT +
"\n" 160 " \"n\" : n, (numeric) index\n" 161 " \"scriptPubKey\" : { (json object)\n" 162 " \"asm\" : \"asm\", (string) the asm\n" 163 " \"hex\" : \"hex\", (string) the hex\n" 164 " \"reqSigs\" : n, (numeric) The required sigs\n" 165 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 166 " \"addresses\" : [ (json array of string)\n" 167 " \"address\" (string) raven address\n" 174 " \"blockhash\" : \"hash\", (string) the block hash\n" 175 " \"confirmations\" : n, (numeric) The confirmations\n" 176 " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n" 177 " \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" 191 bool fVerbose =
false;
213 :
"No such mempool transaction. Use -txindex to enable blockchain transaction queries") +
214 ". Use gettransaction for wallet transactions.");
220 TxToJSON(*tx, hashBlock, result,
true);
228 throw std::runtime_error(
229 "gettxoutproof [\"txid\",...] ( blockhash )\n" 230 "\nReturns a hex-encoded proof that \"txid\" was included in a block.\n" 231 "\nNOTE: By default this function only works sometimes. This is when there is an\n" 232 "unspent output in the utxo for this transaction. To make it always work,\n" 233 "you need to maintain a transaction index, using the -txindex command line option or\n" 234 "specify the block in which the transaction is included manually (by blockhash).\n" 236 "1. \"txids\" (string) A json array of txids to filter\n" 238 " \"txid\" (string) A transaction hash\n" 241 "2. \"blockhash\" (string, optional) If specified, looks for txid in the block with this hash\n" 243 "\"data\" (string) A string that is a serialized, hex-encoded data for the proof.\n" 246 std::set<uint256> setTxids;
249 for (
unsigned int idx = 0; idx < txids.
size(); idx++) {
254 if (setTxids.count(hash))
256 setTxids.insert(hash);
273 for (
const auto& tx : setTxids) {
282 if (pblockindex ==
nullptr)
296 unsigned int ntxFound = 0;
297 for (
const auto& tx : block.
vtx)
298 if (setTxids.count(tx->GetHash()))
300 if (ntxFound != setTxids.size())
313 throw std::runtime_error(
314 "verifytxoutproof \"proof\"\n" 315 "\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" 316 "and throwing an RPC error if the block is not in our best chain\n" 318 "1. \"proof\" (string, required) The hex-encoded proof generated by gettxoutproof\n" 320 "[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof is invalid\n" 329 std::vector<uint256> vMatch;
330 std::vector<unsigned int> vIndex;
331 if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot)
339 for (
const uint256& hash : vMatch)
347 throw std::runtime_error(
348 "createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":(amount or object),\"data\":\"hex\",...} ( locktime ) ( replaceable )\n" 349 "\nCreate a transaction spending the given inputs and creating new outputs.\n" 350 "Outputs are addresses (paired with a RVN amount, data or object specifying an asset operation) or data.\n" 351 "Returns hex-encoded raw transaction.\n" 352 "Note that the transaction's inputs are not signed, and\n" 353 "it is not stored in the wallet or transmitted to the network.\n" 355 "\nPaying for Asset Operations:\n" 356 " Some operations require an amount of RVN to be sent to a burn address:\n" 358 " issue: 500 to Issue Burn Address\n" 359 " issue_unique 5 to Issue Unique Burn Address\n" 360 " reissue: 100 to Reissue Burn Address\n" 361 " transferwithmessage: 0\n" 364 " These operations require an ownership token input for the asset being operated upon:\n" 368 "\nOutput Ordering:\n" 369 " Asset operations require the following:\n" 370 " 1) All coin outputs come first (including the burn output).\n" 371 " 2) The owner token change output comes next (if required).\n" 372 " 3) An issue, issue_unique, reissue or any number of transfers comes last\n" 373 " (different types can't be mixed in a single transaction).\n" 376 "1. \"inputs\" (array, required) A json array of json objects\n" 379 " \"txid\":\"id\", (string, required) The transaction id\n" 380 " \"vout\":n, (number, required) The output number\n" 381 " \"sequence\":n (number, optional) The sequence number\n" 385 "2. \"outputs\" (object, required) a json object with outputs\n" 387 " \"address\": (string, required) The destination raven address. Each output must have a different address.\n" 388 " x.xxx (number or string, required) The RVN amount\n" 390 " { (object) A json object of assets to send\n" 393 " \"asset-name\": (string, required) asset name\n" 394 " asset-quantity (number, required) the number of raw units to transfer\n" 399 " { (object) A json object of describing the transfer and message contents to send\n" 400 " \"transferwithmessage\":\n" 402 " \"asset-name\": (string, required) asset name\n" 403 " asset-quantity, (number, required) the number of raw units to transfer\n" 404 " \"message\":\"hash\", (string, required) ipfs hash or a txid hash\n" 405 " \"expire_time\": n (number, required) utc time in seconds to expire the message\n" 409 " { (object) A json object describing new assets to issue\n" 412 " \"asset_name\":\"asset-name\", (string, required) new asset name\n" 413 " \"asset_quantity\":n, (number, required) the number of raw units to issue\n" 414 " \"units\":[1-8], (number, required) display units, between 1 (integral) to 8 (max precision)\n" 415 " \"reissuable\":[0-1], (number, required) 1=reissuable asset\n" 416 " \"has_ipfs\":[0-1], (number, required) 1=passing ipfs_hash\n" 417 " \"ipfs_hash\":\"hash\" (string, optional) an ipfs hash for discovering asset metadata\n" 421 " { (object) A json object describing new unique assets to issue\n" 422 " \"issue_unique\":\n" 424 " \"root_name\":\"root-name\", (string, required) name of the asset the unique asset(s) are being issued under\n" 425 " \"asset_tags\":[\"asset_tag\", ...], (array, required) the unique tag for each asset which is to be issued\n" 426 " \"ipfs_hashes\":[\"hash\", ...], (array, optional) ipfs hashes corresponding to each supplied tag (should be same size as \"asset_tags\")\n" 430 " { (object) A json object describing follow-on asset issue. Requires matching ownership input.\n" 433 " \"asset_name\":\"asset-name\", (string, required) name of asset to be reissued\n" 434 " \"asset_quantity\":n, (number, required) the number of raw units to issue\n" 435 " \"reissuable\":[0-1], (number, optional) default is 1, 1=reissuable asset\n" 436 " \"ipfs_hash\":\"hash\", (string, optional) An ipfs hash for discovering asset metadata, Overrides the current ipfs hash if given\n" 437 " \"owner_change_address\" (string, optional) the address where the owner token will be sent to. If not given, it will be sent to the output address\n" 441 " { (object) A json object describing how restricted asset to issue\n" 442 " \"issue_restricted\":\n" 444 " \"asset_name\":\"asset-name\",(string, required) new asset name\n" 445 " \"asset_quantity\":n, (number, required) the number of raw units to issue\n" 446 " \"verifier_string\":\"text\", (string, required) the verifier string to be used for a restricted asset transfer verification\n" 447 " \"units\":[1-8], (number, required) display units, between 1 (integral) to 8 (max precision)\n" 448 " \"reissuable\":[0-1], (number, required) 1=reissuable asset\n" 449 " \"has_ipfs\":[0-1], (number, required) 1=passing ipfs_hash\n" 450 " \"ipfs_hash\":\"hash\", (string, optional) an ipfs hash for discovering asset metadata\n" 451 " \"owner_change_address\" (string, optional) the address where the owner token will be sent to. If not given, it will be sent to the output address\n" 455 " \"data\": \"hex\" (string, required) The key is \"data\", the value is hex encoded data\n" 458 "3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" 463 "\"transaction\" (string) hex string of the transaction\n" 466 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0}]\" \"{\\\"address\\\":0.01}\"")
467 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0}]\" \"{\\\"data\\\":\\\"00010203\\\"}\"")
468 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0}]\" \"{\\\"RXissueAssetXXXXXXXXXXXXXXXXXhhZGt\\\":500,\\\"change_address\\\":change_amount,\\\"issuer_address\\\":{\\\"issue\\\":{\\\"asset_name\\\":\\\"MYASSET\\\",\\\"asset_quantity\\\":1000000,\\\"units\\\":1,\\\"reissuable\\\":0,\\\"has_ipfs\\\":1,\\\"ipfs_hash\\\":\\\"43f81c6f2c0593bde5a85e09ae662816eca80797\\\"}}}\"")
469 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0}]\" \"{\\\"RXissueRestrictedXXXXXXXXXXXXzJZ1q\\\":1500,\\\"change_address\\\":change_amount,\\\"issuer_address\\\":{\\\"issue_restricted\\\":{\\\"asset_name\\\":\\\"$MYASSET\\\",\\\"asset_quantity\\\":1000000,\\\"verifier_string\\\":\\\"#TAG & !KYC\\\",\\\"units\\\":1,\\\"reissuable\\\":0,\\\"has_ipfs\\\":1,\\\"ipfs_hash\\\":\\\"43f81c6f2c0593bde5a85e09ae662816eca80797\\\"}}}\"")
470 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0}]\" \"{\\\"RXissueUniqueAssetXXXXXXXXXXWEAe58\\\":20,\\\"change_address\\\":change_amount,\\\"issuer_address\\\":{\\\"issue_unique\\\":{\\\"root_name\\\":\\\"MYASSET\\\",\\\"asset_tags\\\":[\\\"ALPHA\\\",\\\"BETA\\\"],\\\"ipfs_hashes\\\":[\\\"43f81c6f2c0593bde5a85e09ae662816eca80797\\\",\\\"43f81c6f2c0593bde5a85e09ae662816eca80797\\\"]}}}\"")
471 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0},{\\\"txid\\\":\\\"myasset\\\",\\\"vout\\\":0}]\" \"{\\\"address\\\":{\\\"transfer\\\":{\\\"MYASSET\\\":50}}}\"")
472 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0},{\\\"txid\\\":\\\"myasset\\\",\\\"vout\\\":0}]\" \"{\\\"address\\\":{\\\"transferwithmessage\\\":{\\\"MYASSET\\\":50,\\\"message\\\":\\\"hash\\\",\\\"expire_time\\\": utc_time}}}\"")
473 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0},{\\\"txid\\\":\\\"myownership\\\",\\\"vout\\\":0}]\" \"{\\\"issuer_address\\\":{\\\"reissue\\\":{\\\"asset_name\\\":\\\"MYASSET\\\",\\\"asset_quantity\\\":2000000}}}\"")
474 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"mycoin\\\",\\\"vout\\\":0}]\", \"{\\\"data\\\":\\\"00010203\\\"}\"")
488 if (nLockTime < 0 || nLockTime > std::numeric_limits<uint32_t>::max())
495 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
496 const UniValue& input = inputs[idx];
504 int nOutput = vout_v.
get_int();
518 nSequence = std::numeric_limits<uint32_t>::max() - 1;
520 nSequence = std::numeric_limits<uint32_t>::max();
525 if (sequenceObj.
isNum()) {
526 int64_t seqNr64 = sequenceObj.
get_int64();
527 if (seqNr64 < 0 || seqNr64 > std::numeric_limits<uint32_t>::max()) {
530 nSequence = (uint32_t)seqNr64;
536 rawTx.
vin.push_back(in);
541 std::set<CTxDestination> destinations;
542 std::vector<std::string> addrList = sendTo.
getKeys();
543 for (
const std::string& name_ : addrList) {
545 if (name_ ==
"data") {
546 std::vector<unsigned char> data =
ParseHexV(sendTo[name_].getValStr(),
"Data");
549 rawTx.
vout.push_back(out);
556 if (!destinations.insert(destination).second) {
566 CTxOut out(nAmount, scriptPubKey);
567 rawTx.
vout.push_back(out);
571 auto asset_ = sendTo[name_].
get_obj();
572 auto assetKey_ = asset_.
getKeys()[0];
574 if (assetKey_ ==
"issue")
580 auto assetData = asset_.getValues()[0].get_obj();
584 if (!asset_name.
isStr())
588 if (!asset_quantity.
isNum())
596 if (!reissuable.
isNum())
600 if (!has_ipfs.
isNum())
605 ipfs_hash =
find_value(assetData,
"ipfs_hash");
606 if (!ipfs_hash.
isStr())
611 throw JSONRPCError(
RPC_INVALID_PARAMETER,
"Invalid parameter, asset_name can't be a restricted asset name. Please use issue_restricted with the correct parameters");
619 std::string strError =
"";
633 CTxOut ownerOut(0, ownerPubKey);
634 rawTx.
vout.push_back(ownerOut);
641 CTxOut out(0, scriptPubKey);
642 rawTx.
vout.push_back(out);
645 else if (assetKey_ ==
"issue_unique")
651 auto assetData = asset_.getValues()[0].get_obj();
655 if (!root_name.
isStr())
659 if (!asset_tags.
isArray() || asset_tags.
size() < 1)
663 if (!ipfs_hashes.
isNull()) {
664 if (!ipfs_hashes.
isArray() || ipfs_hashes.
size() != asset_tags.
size()) {
665 if (!ipfs_hashes.
isNum())
667 "Invalid parameter, missing asset metadata for key: units");
677 CTxOut out(0, scriptTransferOwnerAsset);
678 rawTx.
vout.push_back(out);
681 for (
int i = 0; i < (int)asset_tags.
size(); i++) {
685 if (ipfs_hashes.
isNull()) {
695 std::string strError =
"";
704 CTxOut out(0, scriptPubKey);
705 rawTx.
vout.push_back(out);
709 else if (assetKey_ ==
"reissue")
715 auto reissueData = asset_.getValues()[0].get_obj();
721 if (!asset_name.
isStr())
725 if (!asset_quantity.
isNum())
729 if (!reissuable.
isNull()) {
730 if (!reissuable.
isNum())
732 "Invalid parameter, missing reissue metadata for key: reissuable");
734 int nReissuable = reissuable.
get_int();
735 if (nReissuable > 1 || nReissuable < 0)
737 "Invalid parameter, reissuable data must be a 0 or 1");
743 if (!ipfs_hash.
isNull()) {
744 if (!ipfs_hash.
isStr())
746 "Invalid parameter, missing reissue metadata for key: ipfs_hash");
750 bool fHasOwnerChange =
false;
751 const UniValue& owner_change_address =
find_value(reissueData,
"owner_change_address");
752 if (!owner_change_address.
isNull()) {
753 if (!owner_change_address.
isStr())
755 "Invalid parameter, owner_change_address must be a string");
756 fHasOwnerChange =
true;
763 throw JSONRPCError(
RPC_INVALID_PARAMETER,
"Invalid parameter, asset_name can't be a restricted asset name. Please use reissue_restricted with the correct parameters");
770 std::string strError;
775 CScript owner_asset_transfer_script;
789 CTxOut out(0, owner_asset_transfer_script);
790 rawTx.
vout.push_back(out);
793 CTxOut out2(0, scriptReissueAsset);
794 rawTx.
vout.push_back(out2);
796 }
else if (assetKey_ ==
"transfer") {
802 auto keys = transferData.
getKeys();
804 if (keys.size() == 0)
808 for (
auto asset_name : keys) {
809 asset_quantity =
find_value(transferData, asset_name);
811 if (!asset_quantity.
isNum())
820 std::string strError =
"";
821 if (!transfer.
IsValid(strError)) {
830 CTxOut out(0, scriptPubKey);
831 rawTx.
vout.push_back(out);
833 }
else if (assetKey_ ==
"transferwithmessage") {
836 "Invalid parameter, the format must follow { \"transferwithmessage\": {\"asset_name\": amount, \"message\": messagehash, \"expire_time\": utc_time} }"));
840 auto keys = transferData.
getKeys();
842 if (keys.size() == 0)
844 "Invalid parameter, the format must follow { \"transferwithmessage\": {\"asset_name\": amount, \"message\": messagehash, \"expire_time\": utc_time} }"));
847 std::string asset_name = keys[0];
851 "Invalid parameter, missing valid asset name to transferwithmessage");
854 if (!asset_quantity.
isNum())
858 if (!message.
isStr())
860 "Invalid parameter, missing reissue data for key: message");
863 if (!expire_time.
isNum())
865 "Invalid parameter, missing reissue data for key: expire_time");
874 std::string strError =
"";
881 transfer.ConstructTransaction(scriptPubKey);
884 CTxOut out(0, scriptPubKey);
885 rawTx.
vout.push_back(out);
887 }
else if (assetKey_ ==
"issue_restricted") {
892 auto assetData = asset_.getValues()[0].get_obj();
896 if (!asset_name.
isStr())
900 if (!asset_quantity.
isNum())
904 if (!verifier_string.
isStr())
912 if (!reissuable.
isNum())
916 if (!has_ipfs.
isNum())
919 bool fHasOwnerChange =
false;
921 if (!owner_change_address.
isNull()) {
922 if (!owner_change_address.
isStr())
924 "Invalid parameter, owner_change_address must be a string");
925 fHasOwnerChange =
true;
933 ipfs_hash =
find_value(assetData,
"ipfs_hash");
934 if (!ipfs_hash.
isStr())
938 std::string strAssetName = asset_name.
get_str();
949 std::string strError =
"";
967 CScript owner_asset_transfer_script;
977 CScript verifier_string_script;
982 CTxOut resissue(0, restricted_issuance_script);
983 CTxOut owner_change(0, owner_asset_transfer_script);
984 CTxOut verifier(0, verifier_string_script);
987 rawTx.
vout.push_back(verifier);
988 rawTx.
vout.push_back(owner_change);
989 rawTx.
vout.push_back(resissue);
992 throw JSONRPCError(
RPC_INVALID_PARAMETER, std::string(
"Invalid parameter, unknown output type (should be 'issue', 'issue_restricted', 'reissue', 'transfer' or 'transferwithmessage'): " + assetKey_));
1011 throw std::runtime_error(
1012 "decoderawtransaction \"hexstring\"\n" 1013 "\nReturn a JSON object representing the serialized, hex-encoded transaction.\n" 1016 "1. \"hexstring\" (string, required) The transaction hex string\n" 1020 " \"txid\" : \"id\", (string) The transaction id\n" 1021 " \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n" 1022 " \"size\" : n, (numeric) The transaction size\n" 1023 " \"vsize\" : n, (numeric) The virtual transaction size (differs from size for witness transactions)\n" 1024 " \"version\" : n, (numeric) The version\n" 1025 " \"locktime\" : ttt, (numeric) The lock time\n" 1026 " \"vin\" : [ (array of json objects)\n" 1028 " \"txid\": \"id\", (string) The transaction id\n" 1029 " \"vout\": n, (numeric) The output number\n" 1030 " \"scriptSig\": { (json object) The script\n" 1031 " \"asm\": \"asm\", (string) asm\n" 1032 " \"hex\": \"hex\" (string) hex\n" 1034 " \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n" 1035 " \"sequence\": n (numeric) The script sequence number\n" 1039 " \"vout\" : [ (array of json objects)\n" 1041 " \"value\" : x.xxx, (numeric) The value in " +
CURRENCY_UNIT +
"\n" 1042 " \"n\" : n, (numeric) index\n" 1043 " \"scriptPubKey\" : { (json object)\n" 1044 " \"asm\" : \"asm\", (string) the asm\n" 1045 " \"hex\" : \"hex\", (string) the hex\n" 1046 " \"reqSigs\" : n, (numeric) The required sigs\n" 1047 " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" 1048 " \"addresses\" : [ (json array of string)\n" 1049 " \"12tvKAXCxZjSmdNbao16dKXC8tRWfcF5oc\" (string) raven address\n" 1080 throw std::runtime_error(
1081 "decodescript \"hexstring\"\n" 1082 "\nDecode a hex-encoded script.\n" 1084 "1. \"hexstring\" (string) the hex encoded script\n" 1087 " \"asm\":\"asm\", (string) Script public key\n" 1088 " \"hex\":\"hex\", (string) hex encoded public key\n" 1089 " \"type\":\"type\", (string) The output type\n" 1090 " \"reqSigs\": n, (numeric) The required signatures\n" 1091 " \"addresses\": [ (json array of string)\n" 1092 " \"address\" (string) raven address\n" 1095 " \"p2sh\":\"address\", (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).\n" 1096 " \"(The following only appears if the script is an asset script)\n" 1097 " \"asset_name\":\"name\", (string) Name of the asset.\n" 1098 " \"amount\":\"x.xx\", (numeric) The amount of assets interacted with.\n" 1099 " \"units\": n, (numeric) The units of the asset. (Only appears in the type (new_asset))\n" 1100 " \"reissuable\": true|false, (boolean) If this asset is reissuable. (Only appears in type (new_asset|reissue_asset))\n" 1101 " \"hasIPFS\": true|false, (boolean) If this asset has an IPFS hash. (Only appears in type (new_asset if hasIPFS is true))\n" 1102 " \"ipfs_hash\": \"hash\", (string) The ipfs hash for the new asset. (Only appears in type (new_asset))\n" 1103 " \"new_ipfs_hash\":\"hash\", (string) If new ipfs hash (Only appears in type. (reissue_asset))\n" 1115 std::vector<unsigned char> scriptData(
ParseHexV(request.
params[0],
"argument"));
1116 script =
CScript(scriptData.begin(), scriptData.end());
1137 std::string address;
1150 std::string address;
1158 bool reissuable = reissue.
nReissuable ? true :
false;
1159 r.
push_back(Pair(
"reissuable", reissuable));
1169 std::string ownerAsset;
1170 std::string address;
1177 bool reissuable = asset.
nReissuable ? true :
false;
1178 r.
push_back(Pair(
"reissuable", reissuable));
1180 bool hasIPFS = asset.
nHasIPFS ? true :
false;
1188 r.
push_back(Pair(
"asset_name", ownerAsset));
1205 static void TxInErrorToJSON(
const CTxIn& txin,
UniValue& vErrorsRet,
const std::string& strMessage)
1214 entry.
push_back(Pair(
"witness", witness));
1217 entry.
push_back(Pair(
"error", strMessage));
1225 throw std::runtime_error(
1226 "combinerawtransaction [\"hexstring\",...]\n" 1227 "\nCombine multiple partially signed transactions into one transaction.\n" 1228 "The combined transaction may be another partially signed transaction or a \n" 1229 "fully signed transaction." 1232 "1. \"txs\" (string) A json array of hex strings of partially signed transactions\n" 1234 " \"hexstring\" (string) A transaction hash\n" 1239 "\"hex\" (string) The hex-encoded raw transaction with signature(s)\n" 1242 +
HelpExampleCli(
"combinerawtransaction",
"[\"myhex1\", \"myhex2\", \"myhex3\"]")
1247 std::vector<CMutableTransaction> txVariants(txs.
size());
1249 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
1250 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str(),
true)) {
1255 if (txVariants.empty()) {
1273 for (
const CTxIn& txin : mergedTx.
vin) {
1284 for (
unsigned int i = 0; i < mergedTx.
vin.size(); i++) {
1297 if (txv.vin.size() > i) {
1310 #ifdef ENABLE_WALLET 1315 throw std::runtime_error(
1316 "signrawtransaction \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] [\"privatekey1\",...] sighashtype )\n" 1317 "\nSign inputs for raw transaction (serialized, hex-encoded).\n" 1318 "The second optional argument (may be null) is an array of previous transaction outputs that\n" 1319 "this transaction depends on but may not yet be in the block chain.\n" 1320 "The third optional argument (may be null) is an array of base58-encoded private\n" 1321 "keys that, if given, will be the only keys used to sign the transaction.\n" 1327 "1. \"hexstring\" (string, required) The transaction hex string\n" 1328 "2. \"prevtxs\" (string, optional) An json array of previous dependent transaction outputs\n" 1329 " [ (json array of json objects, or 'null' if none provided)\n" 1331 " \"txid\":\"id\", (string, required) The transaction id\n" 1332 " \"vout\":n, (numeric, required) The output number\n" 1333 " \"scriptPubKey\": \"hex\", (string, required) script key\n" 1334 " \"redeemScript\": \"hex\", (string, required for P2SH or P2WSH) redeem script\n" 1335 " \"amount\": value (numeric, required) The amount spent\n" 1339 "3. \"privkeys\" (string, optional) A json array of base58-encoded private keys for signing\n" 1340 " [ (json array of strings, or 'null' if none provided)\n" 1341 " \"privatekey\" (string) private key in base58-encoding\n" 1344 "4. \"sighashtype\" (string, optional, default=ALL) The signature hash type. Must be one of\n" 1348 " \"ALL|ANYONECANPAY\"\n" 1349 " \"NONE|ANYONECANPAY\"\n" 1350 " \"SINGLE|ANYONECANPAY\"\n" 1354 " \"hex\" : \"value\", (string) The hex-encoded raw transaction with signature(s)\n" 1355 " \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n" 1356 " \"errors\" : [ (json array of objects) Script verification errors (if there are any)\n" 1358 " \"txid\" : \"hash\", (string) The hash of the referenced, previous transaction\n" 1359 " \"vout\" : n, (numeric) The index of the output to spent and used as input\n" 1360 " \"scriptSig\" : \"hex\", (string) The hex-encoded signature script\n" 1361 " \"sequence\" : n, (numeric) Script sequence number\n" 1362 " \"error\" : \"text\" (string) Verification or signing error related to the input\n" 1374 #ifdef ENABLE_WALLET 1379 RPCTypeCheck(request.
params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR},
true);
1394 for (
const CTxIn& txin : mtx.
vin) {
1401 bool fGivenKeys =
false;
1406 for (
unsigned int idx = 0; idx < keys.
size(); idx++) {
1415 tempKeystore.
AddKey(key);
1418 #ifdef ENABLE_WALLET 1427 for (
unsigned int idx = 0; idx < prevTxs.
size(); idx++) {
1448 std::vector<unsigned char> pkData(
ParseHexO(prevOut,
"scriptPubKey"));
1449 CScript scriptPubKey(pkData.begin(), pkData.end());
1454 std::string err(
"Previous output scriptPubKey mismatch:\n");
1462 if (prevOut.
exists(
"amount")) {
1466 view.
AddCoin(out, std::move(newcoin),
true);
1471 if (fGivenKeys && (scriptPubKey.IsPayToScriptHash() || scriptPubKey.IsPayToWitnessScriptHash())) {
1481 std::vector<unsigned char> rsData(
ParseHexV(v,
"redeemScript"));
1482 CScript redeemScript(rsData.begin(), rsData.end());
1489 #ifdef ENABLE_WALLET 1490 const CKeyStore& keystore = ((fGivenKeys || !pwallet) ? tempKeystore : *pwallet);
1492 const CKeyStore& keystore = tempKeystore;
1497 static std::map<std::string, int> mapSigHashValues = {
1506 if (mapSigHashValues.count(strHashType))
1507 nHashType = mapSigHashValues[strHashType];
1521 for (
unsigned int i = 0; i < mtx.
vin.size(); i++) {
1525 TxInErrorToJSON(txin, vErrors,
"Input not found or already spent");
1533 if (!fHashSingle || (i < mtx.
vout.size()))
1543 TxInErrorToJSON(txin, vErrors,
"Unable to sign input, invalid stack size (possibly missing key)");
1549 bool fComplete = vErrors.
empty();
1553 result.
push_back(Pair(
"complete", fComplete));
1554 if (!vErrors.
empty()) {
1555 result.
push_back(Pair(
"errors", vErrors));
1564 throw std::runtime_error(
1565 "sendrawtransaction \"hexstring\" ( allowhighfees )\n" 1566 "\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n" 1567 "\nAlso see createrawtransaction and signrawtransaction calls.\n" 1569 "1. \"hexstring\" (string, required) The hex string of the raw transaction)\n" 1570 "2. allowhighfees (boolean, optional, default=false) Allow high fees\n" 1572 "\"hex\" (string) The transaction hash in hex\n" 1574 "\nCreate a transaction\n" 1575 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
1576 "Sign the transaction, and get back the hex\n" 1578 "\nSend the transaction (signed hex)\n" 1580 "\nAs a json rpc call\n" 1593 const uint256& hashTx = tx->GetHash();
1600 bool fHaveChain =
false;
1601 for (
size_t o = 0; !fHaveChain && o < tx->vout.size(); o++) {
1603 fHaveChain = !existingCoin.
IsSpent();
1606 if (!fHaveMempool && !fHaveChain) {
1609 bool fMissingInputs;
1611 nullptr ,
false , nMaxRawTxFee)) {
1615 if (fMissingInputs) {
1621 }
else if (fHaveChain) {
1638 {
"rawtransactions",
"getrawtransaction", &
getrawtransaction, {
"txid",
"verbose"} },
1639 {
"rawtransactions",
"createrawtransaction", &
createrawtransaction, {
"inputs",
"outputs",
"locktime"} },
1641 {
"rawtransactions",
"decodescript", &
decodescript, {
"hexstring"} },
1642 {
"rawtransactions",
"sendrawtransaction", &
sendrawtransaction, {
"hexstring",
"allowhighfees"} },
1644 {
"rawtransactions",
"signrawtransaction", &
signrawtransaction, {
"hexstring",
"prevtxs",
"privkeys",
"sighashtype"} },
1646 {
"blockchain",
"gettxoutproof", &
gettxoutproof, {
"txids",
"blockhash"} },
1652 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++)
const Coin & AccessByTxid(const CCoinsViewCache &view, const uint256 &txid)
Utility function to find any unspent output with a given txid.
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
Aliases for backward compatibility.
uint256 ParseHashO(const UniValue &o, std::string strKey)
std::vector< unsigned char > ParseHexO(const UniValue &o, std::string strKey)
void UpdateTransaction(CMutableTransaction &tx, unsigned int nIn, const SignatureData &data)
#define OWNER_ASSET_AMOUNT
#define UNIQUE_ASSET_AMOUNT
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn)
Extract signature data from a transaction, and insert it.
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
void AddCoin(const COutPoint &outpoint, Coin &&coin, bool potential_overwrite)
Add a coin.
void ConstructOwnerTransaction(CScript &script) const
void ConstructTransaction(CScript &script) const
UniValue combinerawtransaction(const JSONRPCRequest &request)
const std::vector< UniValue > & getValues() const
#define UNIQUE_ASSET_UNITS
Raven RPC command dispatcher.
int64_t GetBlockTime() const
enum ScriptError_t ScriptError
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or a pruned one if not found.
void SetBackend(CCoinsView &viewIn)
bool ContextualCheckReissueAsset(CAssetsCache *assetCache, const CReissueAsset &reissue_asset, std::string &strError, const CTransaction &tx)
CCriticalSection cs_wallet
CAmount maxTxFee
Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendra...
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
CScriptWitness scriptWitness
bool AssetFromScript(const CScript &scriptPubKey, CNewAsset &assetNew, std::string &strAddress)
bool TransferAssetFromScript(const CScript &scriptPubKey, CAssetTransfer &assetTransfer, std::string &strAddress)
Get specific asset type metadata from the given scripts.
int Height() const
Return the maximal height in the chain.
CCriticalSection cs_main
Global state.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CTxOut out
unspent transaction output
void ConstructTransaction(CScript &script) const
CTxDestination DecodeDestination(const std::string &str)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
bool AddCScript(const CScript &redeemScript) override
Support for BIP 0013 : see https://github.com/raven/bips/blob/master/bip-0013.mediawiki.
std::vector< std::vector< unsigned char > > stack
UniValue decoderawtransaction(const JSONRPCRequest &request)
const std::string & get_str() const
void ConstructTransaction(CScript &script) const
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const UniValue & get_array() const
const std::string CURRENCY_UNIT
Double ended buffer combining vector and stream-like interfaces.
int64_t get_int64() const
UniValue ValueFromAmount(const CAmount &amount, const int8_t units)
const std::vector< std::string > & getKeys() const
bool ReissueAssetFromScript(const CScript &scriptPubKey, CReissueAsset &reissue, std::string &strAddress)
bool IsValid(std::string &strError) const
std::shared_ptr< const CTransaction > CTransactionRef
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
bool ProduceSignature(const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
#define ASSET_TRANSFER_STRING
std::string HelpRequiringPassphrase(CWallet *const pwallet)
void PushInventory(const CInv &inv)
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValue::VType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
const std::vector< CTxIn > vin
Invalid, missing or duplicate parameter.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
const UniValue & find_value(const UniValue &obj, const std::string &name)
SignatureData CombineSignatures(const CScript &scriptPubKey, const BaseSignatureChecker &checker, const SignatureData &scriptSig1, const SignatureData &scriptSig2)
Combine two script signatures using a generic signature checker, intelligently, possibly with OP_0 pl...
std::string ToString() const
const char * ScriptErrorString(const ScriptError serror)
int64_t CAmount
Amount in corbies (Can be negative)
General error during transaction or block submission.
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
bool IsAssetNameValid(const std::string &name, AssetType &assetType, std::string &error)
#define UNIQUE_ASSETS_REISSUABLE
std::string DecodeAssetData(std::string encoded)
Decode and Encode IPFS hashes, or OIP hashes.
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
bool push_back(const UniValue &val)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
bool AreAssetsDeployed()
RVN START.
base58-encoded Raven addresses.
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool *pfMissingInputs, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, const CAmount nAbsurdFee)
(try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions repla...
UniValue transfer(const JSONRPCRequest &request)
Abstract view on the open txout dataset.
CAssetsCache * GetCurrentAssetCache()
An input of a transaction.
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx, bool fTryNoWitness=false)
void ConstructTransaction(CScript &script) const
Constructs a CScript that carries the asset name and quantity and adds to to the end of the given scr...
bool ContextualCheckNewAsset(CAssetsCache *assetCache, const CNewAsset &asset, std::string &strError, bool fCheckMempool)
const uint256 & GetHash() const
bool exists(const std::string &key) const
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
uint256 uint256S(const char *str)
bool SetString(const char *pszSecret)
std::string GetRejectReason() const
UniValue decodescript(const JSONRPCRequest &request)
bool IsHex(const std::string &str)
const std::vector< CTxOut > vout
Unexpected type was passed as parameter.
bool pushKV(const std::string &key, const UniValue &val)
bool exists(uint256 hash) const
bool OwnerAssetFromScript(const CScript &scriptPubKey, std::string &assetName, std::string &strAddress)
An output of a transaction.
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
std::string ToString() const
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Raven scriptPubKey for the given CTxDestination.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
bool GetSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value)
CAmount AmountFromValue(const UniValue &value)
An outpoint - a combination of a transaction hash and an index n into its vout.
virtual bool AddKey(const CKey &key)
std::vector< CTxOut > vout
void RegisterRawTransactionRPCCommands(CRPCTable &t)
Register raw transaction RPC commands.
std::string GetUniqueAssetName(const std::string &parent, const std::string &tag)
Build a unique asset buy giving the root name, and the tag name (ROOT, TAG) => ROOT::TAG.
std::string GetStrippedVerifierString(const std::string &verifier)
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string strName)
UniValue createrawtransaction(const JSONRPCRequest &request)
void TxToJSON(const CTransaction &tx, const uint256 hashBlock, UniValue &entry, bool expanded=false)
std::vector< CTransactionRef > vtx
bool GetTransaction(const uint256 &hash, CTransactionRef &txOut, const Consensus::Params &consensusParams, uint256 &hashBlock, bool fAllowSlow)
Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock...
const_iterator end() const
std::string EncodeDestination(const CTxDestination &dest)
const_iterator begin() const
UniValue getrawtransaction(const JSONRPCRequest &request)
UniValue verifytxoutproof(const JSONRPCRequest &request)
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
A base58-encoded secret key.
UniValue sendrawtransaction(const JSONRPCRequest &request)
Serialized script, used inside transaction inputs and outputs.
int RPCSerializationFlags()
const UniValue & get_obj() const
A virtual base class for key stores.
A reference to a CKey: the Hash160 of its serialized public key.
bool ContextualCheckVerifierString(CAssetsCache *cache, const std::string &verifier, const std::string &check_address, std::string &strError, bool fWithTags)
std::string GetHex() const
#define ASSET_REISSUE_STRING
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
UniValue gettxoutproof(const JSONRPCRequest &request)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
std::unique_ptr< CConnman > g_connman
CWallet * GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
unsigned int GetRejectCode() const
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
A reference to a CScript: the Hash160 of its serialization (see script.h)
A mutable version of CTransaction.
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0)
UniValue signrawtransaction(const JSONRPCRequest &request)
UniValue JSONRPCError(int code, const std::string &message)
No valid connection manager instance found.
An encapsulated private key.
The basic transaction that is broadcasted on the network and contained in blocks. ...
int nHeight
height of the entry in the chain. The genesis block has height 0
Information about a peer.
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
CCoinsView that brings transactions from a memorypool into view.
std::string EncodeAssetData(std::string decoded)
Basic key store, that keeps keys in an address->secret map.
Wrapper for UniValue::VType, which includes typeAny: Used to denote don't care type.
UniValue reissue(const JSONRPCRequest &request)
Error parsing or validating structure in raw format.
bool IsValid() const
Check whether this private key is valid.
bool IsAssetNameAnRestricted(const std::string &name)
Check if an asset is a restricted asset.
void EnsureWalletIsUnlocked(CWallet *const pwallet)