diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 721d474c2c..6de58f0885 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -619,21 +619,25 @@ static RPCHelpMan getblockheader() {RPCResult::Type::STR_HEX, "chainwork", /*optional=*/true, "Expected number of hashes required to produce the current chain"}, // Not for elements {RPCResult::Type::NUM, "nTx", "The number of transactions in the block"}, {RPCResult::Type::STR, "signblock_challenge", /*optional=*/true, "The challenge for blocksigning (pre-dynafed)"}, - {RPCResult::Type::STR, "signblock_witness_asm", "ASM of sign block witness data"}, - {RPCResult::Type::STR_HEX, "signblock_witness_hex", "Hex of sign block witness data"}, + {RPCResult::Type::STR, "signblock_witness_asm", /*optional=*/true, "ASM of sign block witness data"}, + {RPCResult::Type::STR_HEX, "signblock_witness_hex", "Hex of sign block witness data", {}, /*skip_type_check=*/true}, {RPCResult::Type::OBJ, "dynamic_parameters", /*optional=*/true, "Dynamic federation parameters in the block, if any", { {RPCResult::Type::OBJ, "current", "enforced dynamic federation parameters. The signblockscript is published for each block, while others are published only at epoch start", { {RPCResult::Type::STR_HEX, "signblockscript", "signblock script"}, {RPCResult::Type::NUM, "max_block_witness", "Maximum serialized size of the block witness stack"}, - {RPCResult::Type::STR_HEX, "fedpegscript", "fedpeg script"}, - {RPCResult::Type::ARR, "extension_space", "array of hex-encoded strings", + {RPCResult::Type::STR_HEX, "fedpegscript", /*optional=*/true, "fedpeg script"}, + {RPCResult::Type::STR_HEX, "fedpeg_program", /*optional=*/true, "fedpeg program"}, + {RPCResult::Type::STR_HEX, "root", "The Merkle root"}, + {RPCResult::Type::STR_HEX, "extra_root", "extra Merkle root"}, + {RPCResult::Type::STR, "type", "type of parameter encoding (null, compact, full)"}, + {RPCResult::Type::ARR, "extension_space", /*optional=*/true, "array of hex-encoded strings", { {RPCResult::Type::ELISION, "", ""} }} }}, - {RPCResult::Type::OBJ, "proposed", "Proposed parameters. Uninforced. Must be published in full", + {RPCResult::Type::OBJ, "proposed", "Proposed parameters. Unenforced. Must be published in full", { {RPCResult::Type::ELISION, "", "same entries as current"} }}, @@ -1380,6 +1384,7 @@ RPCHelpMan getblockchaininfo() /* ELEMENTS: not present {RPCResult::Type::STR_HEX, "chainwork", "total amount of work in active chain, in hexadecimal"}, */ {RPCResult::Type::NUM, "size_on_disk", "the estimated size of the block and undo files on disk"}, {RPCResult::Type::BOOL, "pruned", "if the blocks are subject to pruning"}, + {RPCResult::Type::BOOL, "trim_headers", "if trim_headers is enabled"}, {RPCResult::Type::STR_HEX, "current_params_root", /*optional=*/true, "the root of the currently active dynafed params"}, // present if dynafed is active {RPCResult::Type::STR, "signblock_asm", /*optional=*/true, "ASM of sign block challenge data from genesis block"}, // not present if dynafed is active {RPCResult::Type::STR, "signblock_asm", /*optional=*/true, "ASM of sign block challenge data from genesis block"}, // not present if dynafed is active @@ -2365,9 +2370,9 @@ static RPCHelpMan scantxoutset() {RPCResult::Type::BOOL, "coinbase", "Whether this is a coinbase output"}, {RPCResult::Type::NUM, "height", "Height of the unspent transaction output"}, }}, - {RPCResult::Type::STR_AMOUNT, "total_unblinded_bitcoin_amount", "The total amount of all found unspent unblinded outputs in " + CURRENCY_UNIT}, }}, - {RPCResult::Type::STR_AMOUNT, "total_amount", "The total amount of all found unspent outputs in " + CURRENCY_UNIT}, + {RPCResult::Type::STR_AMOUNT, "total_unblinded_bitcoin_amount", "The total amount of all found unspent unblinded outputs in " + CURRENCY_UNIT}, + {RPCResult::Type::STR_AMOUNT, "total_amount", /*optional=*/true, "The total amount of all found unspent outputs in " + CURRENCY_UNIT}, }}, scan_result_abort, scan_result_status_some, @@ -3070,7 +3075,7 @@ static RPCHelpMan loadtxoutset() const std::vector RPCHelpForChainstate{ {RPCResult::Type::NUM, "blocks", "number of blocks in this chainstate"}, {RPCResult::Type::STR_HEX, "bestblockhash", "blockhash of the tip"}, - {RPCResult::Type::NUM, "difficulty", "difficulty of the tip"}, + {RPCResult::Type::NUM, "difficulty", /*optional=*/true, "difficulty of the tip"}, {RPCResult::Type::NUM, "verificationprogress", "progress towards the network tip"}, {RPCResult::Type::STR_HEX, "snapshot_blockhash", /*optional=*/true, "the base block of the snapshot this chainstate is based on, if any"}, {RPCResult::Type::NUM, "coins_db_cache_bytes", "size of the coinsdb cache"}, diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 4fe801b920..e87f324fc2 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -430,8 +430,8 @@ static RPCHelpMan getmininginfo() {RPCResult::Type::NUM, "blocks", "The current block"}, {RPCResult::Type::NUM, "currentblockweight", /*optional=*/true, "The block weight of the last assembled block (only present if a block was ever assembled)"}, {RPCResult::Type::NUM, "currentblocktx", /*optional=*/true, "The number of block transactions of the last assembled block (only present if a block was ever assembled)"}, - {RPCResult::Type::NUM, "difficulty", "The current difficulty"}, - {RPCResult::Type::NUM, "networkhashps", "The network hashes per second"}, + {RPCResult::Type::NUM, "difficulty", /*optional=*/true, "The current difficulty"}, + {RPCResult::Type::NUM, "networkhashps", /*optional=*/true, "The network hashes per second"}, {RPCResult::Type::NUM, "pooledtx", "The size of the mempool"}, {RPCResult::Type::STR, "chain", "current network name (main, test, signet, regtest)"}, {RPCResult::Type::STR, "warnings", "any network and blockchain warnings"}, diff --git a/src/rpc/node.cpp b/src/rpc/node.cpp index 9624da9753..48ad58c88f 100644 --- a/src/rpc/node.cpp +++ b/src/rpc/node.cpp @@ -481,7 +481,7 @@ static RPCHelpMan getpakinfo() RPCResult{ RPCResult::Type::OBJ, "", "", { - {RPCResult::Type::ARR, "block_paklist", "The PAK list loaded from latest epoch", + {RPCResult::Type::OBJ, "block_paklist", "The PAK list loaded from latest epoch", { {RPCResult::Type::ELISION, "", ""} }}, diff --git a/src/rpc/output_script.cpp b/src/rpc/output_script.cpp index 6930dcf1e4..0b779710ef 100644 --- a/src/rpc/output_script.cpp +++ b/src/rpc/output_script.cpp @@ -44,12 +44,18 @@ static RPCHelpMan validateaddress() {RPCResult::Type::BOOL, "iswitness", /*optional=*/true, "If the address is a witness address"}, {RPCResult::Type::NUM, "witness_version", /*optional=*/true, "The version number of the witness program"}, {RPCResult::Type::STR_HEX, "witness_program", /*optional=*/true, "The hex value of the witness program"}, - {RPCResult::Type::STR_HEX, "confidential_key", "the raw blinding public key for that address, if any. \"\" if none"}, - {RPCResult::Type::STR, "unconfidential", "The address without confidentiality key"}, + {RPCResult::Type::STR_HEX, "confidential_key", /*optional=*/true, "the raw blinding public key for that address, if any. \"\" if none"}, + {RPCResult::Type::STR, "unconfidential", /*optional=*/true, "The address without confidentiality key"}, {RPCResult::Type::OBJ, "parent_address_info", /*optional=*/true, "If the address isvalid_parent, this object contains details about the parent address type", { {RPCResult::Type::STR, "address", ""}, - {RPCResult::Type::STR_HEX, "scriptPubKey", ""}, + {RPCResult::Type::STR_HEX, "scriptPubKey", "The hex-encoded scriptPubKey generated by the address"}, + {RPCResult::Type::STR_HEX, "confidential_key", "The raw blinding public key for that address, if any. \"\" if none"}, + {RPCResult::Type::STR_HEX, "unconfidential", "The address without confidentiality key"}, + {RPCResult::Type::BOOL, "isscript", "If the key is a script"}, + {RPCResult::Type::BOOL, "iswitness", "If the address is a witness address"}, + {RPCResult::Type::NUM, "witness_version", /*optional=*/true, "The version number of the witness program"}, + {RPCResult::Type::STR_HEX, "witness_program", /*optional=*/true, "The hex value of the witness program"}, }}, {RPCResult::Type::STR, "error", /*optional=*/true, "Error message, if any"}, {RPCResult::Type::STR, "error_parent", /* optional */ true, "Error message, if any"}, diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 0ba7a537ff..2f9194a718 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -103,7 +103,7 @@ static std::vector ScriptPubKeyDoc() { {RPCResult::Type::STR, "pegout_asm", /*optional=*/true, "(only pegout) pegout scriptpubkey (asm)"}, {RPCResult::Type::STR_HEX, "pegout_hex", /*optional=*/true, "(only pegout) pegout scriptpubkey (hex)"}, {RPCResult::Type::STR_HEX, "pegout_chain", /*optional=*/true, "(only pegout) Hash of genesis block of parent chain"}, - {RPCResult::Type::STR_HEX, "pegout_desc", /*optional=*/true, ""}, // ELEMENTS FIXME: what is thiss field for? + {RPCResult::Type::STR_HEX, "pegout_desc", /*optional=*/true, "(only pegout) Inferred descriptor for the pegout"}, {RPCResult::Type::STR, "pegout_type", /*optional=*/true, "(only pegout) The pegout type, eg 'pubkeyhash'"}, {RPCResult::Type::STR, "type", "The type (one of: " + GetAllOutputTypes() + ")"}, {RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"}, @@ -120,6 +120,8 @@ static std::vector DecodeTxDoc(const std::string& txid_field_doc) {RPCResult::Type::NUM, "size", "The serialized transaction size"}, {RPCResult::Type::NUM, "vsize", "The virtual transaction size (differs from size for witness transactions)"}, {RPCResult::Type::NUM, "weight", "The transaction's weight (between vsize*4-3 and vsize*4)"}, + {RPCResult::Type::NUM, "discountvsize", /*optional=*/true, "The discounted virtual transaction size, only differs from vsize for Confidential Transactions"}, + {RPCResult::Type::NUM, "discountweight", /*optional=*/true, "The discounted transaction weight, only differs from weight for Confidential Transactions"}, {RPCResult::Type::STR_HEX, "withash", /*optional=*/true, "The hash of the witness"}, {RPCResult::Type::STR_HEX, "wtxid", /*optional=*/true, "Hash of the serialized transaction, including witness data"}, {RPCResult::Type::NUM, "version", "The version"}, @@ -141,11 +143,23 @@ static std::vector DecodeTxDoc(const std::string& txid_field_doc) {RPCResult::Type::STR_HEX, "hex", "hex-encoded witness data (if any)"}, }}, {RPCResult::Type::NUM, "sequence", "The script sequence number"}, - {RPCResult::Type::BOOL, "is_pegin", "Is this input a pegin"}, + {RPCResult::Type::BOOL, "is_pegin", /*optional=*/true, "Is this input a pegin"}, {RPCResult::Type::ARR, "pegin_witness", /*optional=*/true, "", { {RPCResult::Type::STR_HEX, "", "hex-encoded witness data (if any)"}, }}, + {RPCResult::Type::OBJ, "issuance", /*optional=*/true, "", + { + {RPCResult::Type::STR_HEX, "assetBlindingNonce", /*optional=*/true, ""}, + {RPCResult::Type::STR_HEX, "assetEntropy", /*optional=*/true, ""}, + {RPCResult::Type::BOOL, "isreissuance", /*optional=*/true, ""}, + {RPCResult::Type::STR_HEX, "token", /*optional=*/true, ""}, + {RPCResult::Type::STR_HEX, "asset", /*optional=*/true, ""}, + {RPCResult::Type::STR_AMOUNT, "assetamount", /*optional=*/true, ""}, + {RPCResult::Type::STR_HEX, "assetamountcommitment", /*optional=*/true, ""}, + {RPCResult::Type::STR_AMOUNT, "tokenamount", /*optional=*/true, ""}, + {RPCResult::Type::STR_HEX, "tokenamountcommitment", /*optional=*/true, ""}, + }}, }}, }}, {RPCResult::Type::ARR, "vout", "", @@ -156,7 +170,7 @@ static std::vector DecodeTxDoc(const std::string& txid_field_doc) {RPCResult::Type::STR_HEX, "asset", /*optional=*/true, "Asset type for issuance if known"}, {RPCResult::Type::STR_HEX, "assetcommitment", /*optional=*/true, "Commitment for the asset"}, {RPCResult::Type::STR_HEX, "commitmentnonce", "The commitment nonce"}, - {RPCResult::Type::BOOL, "commitmentnonce_fully_valid", "Whether the commitment nonce is fully valid"}, // ELEMENTS: FIXME (this is a pretty bad explanation) + {RPCResult::Type::BOOL, "commitmentnonce_fully_valid", "Whether the commitment nonce is a valid pubkey"}, {RPCResult::Type::NUM, "ct-bits", /*optional=*/true, "The mantissa of the range proof"}, {RPCResult::Type::NUM, "ct-exponent", /*optional=*/true, "The exponent of the range proof"}, {RPCResult::Type::NUM, "n", "index"}, @@ -840,7 +854,7 @@ static RPCHelpMan signrawtransactionwithkey() {RPCResult::Type::STR, "error", "Verification or signing error related to the input"}, }}, }}, - {RPCResult::Type::STR, "warning", "Warning that a peg-in input signed may be immature. This could mean lack of connectivity to or misconfiguration of the daemon"}, + {RPCResult::Type::STR, "warning", /*optional=*/true, "Warning that a peg-in input signed may be immature. This could mean lack of connectivity to or misconfiguration of the daemon"}, } }, RPCExamples{ @@ -896,7 +910,10 @@ const RPCResult decodepsbt_inputs{ }}, {RPCResult::Type::OBJ, "witness_utxo", /*optional=*/true, "Transaction output for witness UTXOs", { - {RPCResult::Type::NUM, "amount", "The value in " + CURRENCY_UNIT}, + {RPCResult::Type::NUM, "amount", /*optional=*/true, "The value in " + CURRENCY_UNIT}, + {RPCResult::Type::STR_HEX, "asset", /*optional=*/true, "The asset type"}, + {RPCResult::Type::STR_HEX, "amountcommitment", /*optional=*/true, "The amount commitment"}, + {RPCResult::Type::STR_HEX, "assetcommitment", /*optional=*/true, "The asset commitment"}, {RPCResult::Type::OBJ, "scriptPubKey", "", { {RPCResult::Type::STR, "asm", "Disassembly of the public key script"}, @@ -1008,6 +1025,20 @@ const RPCResult decodepsbt_inputs{ {RPCResult::Type::STR_HEX, "value", "The hex for the value"}, }}, }}, + {RPCResult::Type::STR_HEX, "previous_txid", /*optional=*/ true, "The TXID of the prevout"}, + {RPCResult::Type::NUM, "previous_vout", /*optional=*/ true, "The output index of the prevout"}, + {RPCResult::Type::NUM, "sequence", /*optional=*/ true, "The sequence number"}, + {RPCResult::Type::STR_HEX, "pegin_bitcoin_tx", /*optional=*/ true, "The hex-encoded Bitcoin transaction"}, + {RPCResult::Type::STR_HEX, "pegin_claim_script", /*optional=*/ true, "The peg-in claim script"}, + {RPCResult::Type::STR_HEX, "pegin_genesis_hash", /*optional=*/ true, "The hex-encoded genesis block hash of the parent chain"}, + {RPCResult::Type::STR_HEX, "pegin_txout_proof", /*optional=*/ true, "The hex-encoded raw txout proof"}, + {RPCResult::Type::STR_AMOUNT, "pegin_value", /*optional=*/ true, "The peg-in value"}, + {RPCResult::Type::STR_HEX, "utxo_rangeproof", /*optional=*/ true, "The UTXO range proof"}, + {RPCResult::Type::STR_HEX, "asset_proof", /*optional=*/ true, "The asset proof"}, + {RPCResult::Type::STR_HEX, "explicit_asset", /*optional=*/ true, "The explicit asset type"}, + {RPCResult::Type::STR_AMOUNT, "explicit_value", /*optional=*/ true, "The explicit value"}, + {RPCResult::Type::STR_HEX, "value_proof", /*optional=*/ true, "The value proof"}, + {RPCResult::Type::STR, "status", /*optional=*/true, "Status"}, }}, } }; @@ -1075,6 +1106,26 @@ const RPCResult decodepsbt_outputs{ {RPCResult::Type::STR_HEX, "value", "The hex for the value"}, }}, }}, + {RPCResult::Type::NUM, "amount", /*optional=*/true, "The value in " + CURRENCY_UNIT}, + {RPCResult::Type::STR_HEX, "asset", /*optional=*/true, "The asset type"}, + {RPCResult::Type::OBJ, "script", "", + { + {RPCResult::Type::STR, "asm", "Disassembly of the public key script"}, + {RPCResult::Type::STR, "desc", "Inferred descriptor for the output"}, + {RPCResult::Type::STR_HEX, "hex", "The raw public key script bytes, hex-encoded"}, + {RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"}, + {RPCResult::Type::STR, "address", /*optional=*/true, "The Bitcoin address (only if a well-defined address exists)"}, + }}, + {RPCResult::Type::NUM, "blinder_index", /*optional=*/true, "Output index of the blinder for this output"}, + {RPCResult::Type::STR_HEX, "blinding_pubkey", /*optional=*/true, "The blinding pubkey"}, + {RPCResult::Type::STR, "status", /*optional=*/true, "Status"}, + {RPCResult::Type::STR, "asset_commitment", /*optional=*/true, "The asset commitment"}, + {RPCResult::Type::STR, "blind_asset_proof", /*optional=*/true, "The blind asset proof"}, + {RPCResult::Type::STR, "blind_value_proof", /*optional=*/true, "The blind value proof"}, + {RPCResult::Type::STR, "ecdh_pubkey", /*optional=*/true, "The ECDH pubkey"}, + {RPCResult::Type::STR, "rangeproof", /*optional=*/true, "The rangeproof"}, + {RPCResult::Type::STR, "surjection_proof", /*optional=*/true, "The surjection proof"}, + {RPCResult::Type::STR, "value_commitment", /*optional=*/true, "The value commitment"}, }}, } }; @@ -1091,7 +1142,7 @@ static RPCHelpMan decodepsbt() RPCResult{ RPCResult::Type::OBJ, "", "", { - {RPCResult::Type::OBJ, "tx", "The decoded network-serialized unsigned transaction.", + {RPCResult::Type::OBJ, "tx", /*optional=*/true, "The decoded network-serialized unsigned transaction.", { {RPCResult::Type::ELISION, "", "The layout is the same as the output of decoderawtransaction."}, }}, @@ -1105,21 +1156,21 @@ static RPCHelpMan decodepsbt() }}, }}, {RPCResult::Type::NUM, "tx_version", "The version number of the unsigned transaction. Not to be confused with PSBT version"}, - {RPCResult::Type::NUM, "fallback_locktime", "The locktime to fallback to if no inputs specify a required locktime."}, + {RPCResult::Type::NUM, "fallback_locktime", /*optional=*/true, "The locktime to fallback to if no inputs specify a required locktime."}, {RPCResult::Type::NUM, "fees", "The fees specified in this psbt.", {}, /*skip_type_check=*/true}, // ELEMENTS has an explicit fee output, bitcoin does not (they are implicit) {RPCResult::Type::NUM, "input_count", "The number of inputs in this psbt"}, {RPCResult::Type::NUM, "output_count", "The number of outputs in this psbt."}, - {RPCResult::Type::NUM, "inputs_modifiable", "Whether inputs can be modified"}, - {RPCResult::Type::NUM, "outputs_modifiable", "Whether outputs can be modified"}, - {RPCResult::Type::ARR, "sighash_single_indexes", "The indexes which have SIGHASH_SINGLE signatures", + {RPCResult::Type::NUM, "inputs_modifiable", /*optional=*/true, "Whether inputs can be modified"}, + {RPCResult::Type::NUM, "outputs_modifiable", /*optional=*/true, "Whether outputs can be modified"}, + {RPCResult::Type::ARR, "sighash_single_indexes", /*optional=*/true, "The indexes which have SIGHASH_SINGLE signatures", {{RPCResult::Type::NUM, "", "Index of an input with a SIGHASH_SINGLE signature"}}, }, {RPCResult::Type::NUM, "psbt_version", "The PSBT version number. Not to be confused with the unsigned transaction version"}, - {RPCResult::Type::OBJ_DYN, "scalar_offsets", "The PSET scalar elements", + {RPCResult::Type::ARR, "scalar_offsets", /*optional=*/true, "The PSET scalar elements", { {RPCResult::Type::STR_HEX, "scalar", "A scalar offset stored in the PSET"}, }}, - {RPCResult::Type::OBJ, "proprietary", "The global proprietary map", + {RPCResult::Type::ARR, "proprietary", "The global proprietary map", { {RPCResult::Type::OBJ, "", "", { @@ -1136,7 +1187,7 @@ static RPCHelpMan decodepsbt() decodepsbt_inputs, decodepsbt_outputs, {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The transaction fee paid if all UTXOs slots in the PSBT have been filled."}, - }, /*skip_type_check=*/true // ELEMENTS FIXME: go through and make the types correct in these docs, and then remove this argument. If we remove it now, every call will throw an exception + } }, RPCExamples{ HelpExampleCli("decodepsbt", "\"psbt\"") @@ -2389,7 +2440,7 @@ static RPCHelpMan analyzepsbt() {RPCResult::Type::STR, "next", /*optional=*/true, "Role of the next person that this input needs to go to"}, }}, }}, - {RPCResult::Type::ARR, "outputs", "", + {RPCResult::Type::ARR, "outputs", /*optional=*/true, "", { {RPCResult::Type::OBJ, "", "", { @@ -2819,7 +2870,7 @@ static RPCHelpMan rawissueasset() { {RPCResult::Type::OBJ, "", "", { - {RPCResult::Type::STR_HEX, "hex", "The transaction with issuances appended. Only appended to final index in returned array"}, + {RPCResult::Type::STR_HEX, "hex", /*optional=*/true, "The transaction with issuances appended. Only appended to final index in returned array"}, {RPCResult::Type::NUM, "vin", "The input position of the issuance in the transaction"}, {RPCResult::Type::STR_HEX, "entropy", "Entropy of the asset type"}, {RPCResult::Type::STR_HEX, "asset", "Asset type for issuance if known"}, diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 8338dc1474..018b16643e 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -1086,19 +1086,17 @@ static std::optional ExpectedType(RPCResult::Type type) UniValue RPCResult::MatchesType(const UniValue& result) const { - /* ELEMENTS FIXME: this bitcoin code applies strict type checks to each RPC call's docs. - The elements documentation is not up to date, and it is a lot of work to get all the types specified correctly. - For now, we have disabled these type checks. The result is that the RPC results specified in the man pages - are often incorrect and/or missing some parameters. - - TODO: uncomment this code, remove the 'return' above, and fix the RPC docs. */ - // if (m_skip_type_check) { - // return true; - // } + if (m_skip_type_check) { + return true; + } const auto exp_type = ExpectedType(m_type); if (!exp_type) return true; // can be any type, so nothing to check + // ELEMENTS: the majority of any RPCResult type checking is now fixed, + // but leaving this disabled for now in case there are any conditional + // differences that are not yet tested. + // if (*exp_type != result.getType()) { // return strprintf("returned type is %s, but declared as %s in doc", uvTypeName(result.getType()), uvTypeName(*exp_type)); // } diff --git a/src/wallet/rpc/coins.cpp b/src/wallet/rpc/coins.cpp index 0d9ef16a84..5ba008b30f 100644 --- a/src/wallet/rpc/coins.cpp +++ b/src/wallet/rpc/coins.cpp @@ -492,16 +492,44 @@ RPCHelpMan getbalances() { {RPCResult::Type::OBJ, "mine", "balances from outputs that the wallet can sign", { - {RPCResult::Type::STR_AMOUNT, "trusted", "trusted balance (outputs created by the wallet or confirmed outputs)"}, - {RPCResult::Type::STR_AMOUNT, "untrusted_pending", "untrusted pending balance (outputs created by others that are in the mempool)"}, - {RPCResult::Type::STR_AMOUNT, "immature", "balance from immature coinbase outputs"}, - {RPCResult::Type::STR_AMOUNT, "used", /*optional=*/true, "(only present if avoid_reuse is set) balance from coins sent to addresses that were previously spent from (potentially privacy violating)"}, + {RPCResult::Type::OBJ, "trusted", "trusted balance (outputs created by the wallet or confirmed outputs)", + { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }, + }, + {RPCResult::Type::OBJ, "untrusted_pending", "untrusted pending balance (outputs created by others that are in the mempool)", + { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }, + }, + {RPCResult::Type::OBJ, "immature", "balance from immature coinbase outputs", + { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }, + }, + {RPCResult::Type::OBJ, "used", /*optional=*/true, "(only present if avoid_reuse is set) balance from coins sent to addresses that were previously spent from (potentially privacy violating)", + { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }, + }, }}, {RPCResult::Type::OBJ, "watchonly", /*optional=*/true, "watchonly balances (not present if wallet does not watch anything)", { - {RPCResult::Type::STR_AMOUNT, "trusted", "trusted balance (outputs created by the wallet or confirmed outputs)"}, - {RPCResult::Type::STR_AMOUNT, "untrusted_pending", "untrusted pending balance (outputs created by others that are in the mempool)"}, - {RPCResult::Type::STR_AMOUNT, "immature", "balance from immature coinbase outputs"}, + {RPCResult::Type::OBJ, "trusted", "trusted balance (outputs created by the wallet or confirmed outputs)", + { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }, + }, + {RPCResult::Type::OBJ, "untrusted_pending", "untrusted pending balance (outputs created by others that are in the mempool)", + { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }, + }, + {RPCResult::Type::OBJ, "immature", "balance from immature coinbase outputs", + { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }, + }, }}, RESULT_LAST_PROCESSED_BLOCK, } @@ -590,9 +618,9 @@ RPCHelpMan listunspent() {RPCResult::Type::STR, "label", /*optional=*/true, "The associated label, or \"\" for the default label"}, {RPCResult::Type::STR, "scriptPubKey", "the script key"}, {RPCResult::Type::STR_AMOUNT, "amount", "the transaction output amount in " + CURRENCY_UNIT}, - {RPCResult::Type::STR_HEX, "amountcommitment", "the transaction output commitment in hex"}, + {RPCResult::Type::STR_HEX, "amountcommitment", /*optional=*/true, "the transaction output commitment in hex"}, {RPCResult::Type::STR_HEX, "asset", "the transaction output asset in hex"}, - {RPCResult::Type::STR_HEX, "assetcommitment", "the transaction output asset commitment in hex"}, + {RPCResult::Type::STR_HEX, "assetcommitment", /*optional=*/true, "the transaction output asset commitment in hex"}, {RPCResult::Type::STR_HEX, "amountblinder", "the transaction output amount blinding factor in hex"}, {RPCResult::Type::STR_HEX, "assetblinder", "the transaction output asset blinding factor in hex"}, {RPCResult::Type::NUM, "confirmations", "The number of confirmations"}, diff --git a/src/wallet/rpc/elements.cpp b/src/wallet/rpc/elements.cpp index 20d024fb8c..c20d39e26c 100644 --- a/src/wallet/rpc/elements.cpp +++ b/src/wallet/rpc/elements.cpp @@ -456,7 +456,7 @@ RPCHelpMan sendtomainchain_base() RPCResult::Type::OBJ, "", "", { {RPCResult::Type::STR_HEX, "txid", "The transaction id."}, - {RPCResult::Type::STR, "fee reason", "The transaction fee reason."} + {RPCResult::Type::STR, "fee reason", /*optional=*/true, "The transaction fee reason."} }, }, }, @@ -568,7 +568,7 @@ RPCHelpMan sendtomainchain_pak() { {RPCResult::Type::STR, "bitcoin_address", "destination address on Bitcoin mainchain"}, {RPCResult::Type::STR_HEX, "txid", "transaction ID of the resulting Liquid transaction"}, - {RPCResult::Type::STR, "fee reason", "If verbose is set to true, the Liquid transaction fee reason"}, + {RPCResult::Type::STR, "fee reason", /*optional=*/true, "If verbose is set to true, the Liquid transaction fee reason"}, {RPCResult::Type::STR, "bitcoin_descriptor", "xpubkey of the child destination address"}, {RPCResult::Type::STR, "bip32_counter", "derivation counter for the `bitcoin_descriptor`"}, }, @@ -905,7 +905,7 @@ RPCHelpMan createrawpegin() RPCResult::Type::OBJ, "", "", { {RPCResult::Type::STR, "hex", "raw transaction data"}, - {RPCResult::Type::BOOL, "mature", "Whether the peg-in is mature (only included when validating peg-ins)"}, + {RPCResult::Type::BOOL, "mature", /*optional=*/true, "Whether the peg-in is mature (only included when validating peg-ins)"}, }, }, RPCExamples{ @@ -1609,14 +1609,14 @@ RPCHelpMan listissuances() {RPCResult::Type::STR_HEX, "txid", "Transaction id for issuance"}, {RPCResult::Type::STR_HEX, "entropy", "Entropy of the asset type"}, {RPCResult::Type::STR_HEX, "asset", "Asset type for issuance if known"}, - {RPCResult::Type::STR, "assetlabel", "Asset label for issuance if set"}, - {RPCResult::Type::STR_HEX, "token", "Token type for issuancen"}, + {RPCResult::Type::STR, "assetlabel", /*optional=*/true, "Asset label for issuance if set"}, + {RPCResult::Type::STR_HEX, "token", /*optional=*/true, "Token type for issuancen"}, {RPCResult::Type::NUM, "vin", "The input position of the issuance in the transaction"}, {RPCResult::Type::STR_AMOUNT, "assetamount", "The amount of asset issued. Is -1 if blinded and unknown to wallet"}, - {RPCResult::Type::STR_AMOUNT, "tokenamount", "The reissuance token amount issued. Is -1 if blinded and unknown to wallet"}, + {RPCResult::Type::STR_AMOUNT, "tokenamount", /*optional=*/true, "The reissuance token amount issued. Is -1 if blinded and unknown to wallet"}, {RPCResult::Type::BOOL, "isreissuance", "Whether this is a reissuance"}, {RPCResult::Type::STR_HEX, "assetblinds", "Blinding factor for asset amounts"}, - {RPCResult::Type::STR_HEX, "tokenblinds", "Blinding factor for token amounts"}, + {RPCResult::Type::STR_HEX, "tokenblinds", /*optional=*/true, "Blinding factor for token amounts"}, }}, } }, diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index 005e4cb3a5..16b445d270 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -242,7 +242,7 @@ RPCHelpMan listreceivedbyaddress() { {RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction"}, {RPCResult::Type::STR, "address", "The receiving address"}, - {RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " received by the address"}, + {RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " received by the address", {}, /*skip_type_check=*/true}, {RPCResult::Type::NUM, "confirmations", "The number of confirmations of the most recent transaction included"}, {RPCResult::Type::STR, "label", "The label of the receiving address. The default label is \"\""}, {RPCResult::Type::ARR, "txids", "", @@ -293,7 +293,9 @@ RPCHelpMan listreceivedbylabel() {RPCResult::Type::OBJ, "", "", { {RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/true, "Only returns true if imported addresses were involved in transaction"}, - {RPCResult::Type::STR_AMOUNT, "amount", "The total amount received by addresses with this label"}, + {RPCResult::Type::OBJ, "amount", "The total amount received by addresses with this label", { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }}, {RPCResult::Type::NUM, "confirmations", "The number of confirmations of the most recent transaction included"}, {RPCResult::Type::STR, "label", "The label of the receiving address. The default label is \"\""}, }}, @@ -492,6 +494,9 @@ RPCHelpMan listtransactions() "\"orphan\" Orphaned coinbase transactions received."}, {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n" "for all other categories"}, + {RPCResult::Type::STR_HEX, "amountblinder", /*optional=*/true, "The amount blinder"}, + {RPCResult::Type::STR_HEX, "asset", /*optional=*/true, "The asset type"}, + {RPCResult::Type::STR_HEX, "assetblinder", /*optional=*/true, "The asset blinder"}, {RPCResult::Type::STR, "label", /*optional=*/true, "A comment for the address/transaction, if any"}, {RPCResult::Type::NUM, "vout", "the vout value"}, {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the\n" @@ -607,6 +612,9 @@ RPCHelpMan listsinceblock() {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n" "for all other categories"}, {RPCResult::Type::NUM, "vout", "the vout value"}, + {RPCResult::Type::STR_HEX, "amountblinder", /*optional=*/true, "The amount blinder"}, + {RPCResult::Type::STR_HEX, "asset", /*optional=*/true, "The asset type"}, + {RPCResult::Type::STR_HEX, "assetblinder", /*optional=*/true, "The asset blinder"}, {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the\n" "'send' category of transactions."}, }, diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp index c306d291b6..05e4ba025a 100644 --- a/src/wallet/rpc/wallet.cpp +++ b/src/wallet/rpc/wallet.cpp @@ -660,7 +660,10 @@ RPCHelpMan simulaterawtransaction() RPCResult{ RPCResult::Type::OBJ, "", "", { - {RPCResult::Type::STR_AMOUNT, "balance_change", "The wallet balance change (negative means decrease)."}, + {RPCResult::Type::OBJ, "balance_change", "The wallet balance change (negative means decrease).", + { + {RPCResult::Type::ELISION, "", "the amount for each asset"}, + }}, } }, RPCExamples{