Skip to content

Commit 862a686

Browse files
committed
rpc: fix rpc typechecking errors
Fixes (most?) of the rpc typechecking errors, at least the ones that are tested by the functional tests. However, I've left the rpc typechecking off after fixing these, since I'm concerned that there are conditional cases that are untested in our functional tests - and I'd rather not have RPC calls failing in a release just because the documentation is not correct.
1 parent 9b12523 commit 862a686

File tree

10 files changed

+156
-57
lines changed

10 files changed

+156
-57
lines changed

src/rpc/blockchain.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,21 +619,25 @@ static RPCHelpMan getblockheader()
619619
{RPCResult::Type::STR_HEX, "chainwork", /*optional=*/true, "Expected number of hashes required to produce the current chain"}, // Not for elements
620620
{RPCResult::Type::NUM, "nTx", "The number of transactions in the block"},
621621
{RPCResult::Type::STR, "signblock_challenge", /*optional=*/true, "The challenge for blocksigning (pre-dynafed)"},
622-
{RPCResult::Type::STR, "signblock_witness_asm", "ASM of sign block witness data"},
623-
{RPCResult::Type::STR_HEX, "signblock_witness_hex", "Hex of sign block witness data"},
622+
{RPCResult::Type::STR, "signblock_witness_asm", /*optional=*/true, "ASM of sign block witness data"},
623+
{RPCResult::Type::STR_HEX, "signblock_witness_hex", "Hex of sign block witness data", {}, /*skip_type_check=*/true},
624624
{RPCResult::Type::OBJ, "dynamic_parameters", /*optional=*/true, "Dynamic federation parameters in the block, if any",
625625
{
626626
{RPCResult::Type::OBJ, "current", "enforced dynamic federation parameters. The signblockscript is published for each block, while others are published only at epoch start",
627627
{
628628
{RPCResult::Type::STR_HEX, "signblockscript", "signblock script"},
629629
{RPCResult::Type::NUM, "max_block_witness", "Maximum serialized size of the block witness stack"},
630-
{RPCResult::Type::STR_HEX, "fedpegscript", "fedpeg script"},
631-
{RPCResult::Type::ARR, "extension_space", "array of hex-encoded strings",
630+
{RPCResult::Type::STR_HEX, "fedpegscript", /*optional=*/true, "fedpeg script"},
631+
{RPCResult::Type::STR_HEX, "fedpeg_program", /*optional=*/true, "fedpeg program"},
632+
{RPCResult::Type::STR_HEX, "root", "The Merkle root"},
633+
{RPCResult::Type::STR_HEX, "extra_root", "extra Merkle root"},
634+
{RPCResult::Type::STR, "type", "type of parameter encoding (null, compact, full)"},
635+
{RPCResult::Type::ARR, "extension_space", /*optional=*/true, "array of hex-encoded strings",
632636
{
633637
{RPCResult::Type::ELISION, "", ""}
634638
}}
635639
}},
636-
{RPCResult::Type::OBJ, "proposed", "Proposed parameters. Uninforced. Must be published in full",
640+
{RPCResult::Type::OBJ, "proposed", "Proposed parameters. Unenforced. Must be published in full",
637641
{
638642
{RPCResult::Type::ELISION, "", "same entries as current"}
639643
}},
@@ -1380,6 +1384,7 @@ RPCHelpMan getblockchaininfo()
13801384
/* ELEMENTS: not present {RPCResult::Type::STR_HEX, "chainwork", "total amount of work in active chain, in hexadecimal"}, */
13811385
{RPCResult::Type::NUM, "size_on_disk", "the estimated size of the block and undo files on disk"},
13821386
{RPCResult::Type::BOOL, "pruned", "if the blocks are subject to pruning"},
1387+
{RPCResult::Type::BOOL, "trim_headers", "if trim_headers is enabled"},
13831388
{RPCResult::Type::STR_HEX, "current_params_root", /*optional=*/true, "the root of the currently active dynafed params"}, // present if dynafed is active
13841389
{RPCResult::Type::STR, "signblock_asm", /*optional=*/true, "ASM of sign block challenge data from genesis block"}, // not present if dynafed is active
13851390
{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()
23652370
{RPCResult::Type::BOOL, "coinbase", "Whether this is a coinbase output"},
23662371
{RPCResult::Type::NUM, "height", "Height of the unspent transaction output"},
23672372
}},
2368-
{RPCResult::Type::STR_AMOUNT, "total_unblinded_bitcoin_amount", "The total amount of all found unspent unblinded outputs in " + CURRENCY_UNIT},
23692373
}},
2370-
{RPCResult::Type::STR_AMOUNT, "total_amount", "The total amount of all found unspent outputs in " + CURRENCY_UNIT},
2374+
{RPCResult::Type::STR_AMOUNT, "total_unblinded_bitcoin_amount", "The total amount of all found unspent unblinded outputs in " + CURRENCY_UNIT},
2375+
{RPCResult::Type::STR_AMOUNT, "total_amount", /*optional=*/true, "The total amount of all found unspent outputs in " + CURRENCY_UNIT},
23712376
}},
23722377
scan_result_abort,
23732378
scan_result_status_some,
@@ -3070,7 +3075,7 @@ static RPCHelpMan loadtxoutset()
30703075
const std::vector<RPCResult> RPCHelpForChainstate{
30713076
{RPCResult::Type::NUM, "blocks", "number of blocks in this chainstate"},
30723077
{RPCResult::Type::STR_HEX, "bestblockhash", "blockhash of the tip"},
3073-
{RPCResult::Type::NUM, "difficulty", "difficulty of the tip"},
3078+
{RPCResult::Type::NUM, "difficulty", /*optional=*/true, "difficulty of the tip"},
30743079
{RPCResult::Type::NUM, "verificationprogress", "progress towards the network tip"},
30753080
{RPCResult::Type::STR_HEX, "snapshot_blockhash", /*optional=*/true, "the base block of the snapshot this chainstate is based on, if any"},
30763081
{RPCResult::Type::NUM, "coins_db_cache_bytes", "size of the coinsdb cache"},

src/rpc/mining.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ static RPCHelpMan getmininginfo()
430430
{RPCResult::Type::NUM, "blocks", "The current block"},
431431
{RPCResult::Type::NUM, "currentblockweight", /*optional=*/true, "The block weight of the last assembled block (only present if a block was ever assembled)"},
432432
{RPCResult::Type::NUM, "currentblocktx", /*optional=*/true, "The number of block transactions of the last assembled block (only present if a block was ever assembled)"},
433-
{RPCResult::Type::NUM, "difficulty", "The current difficulty"},
434-
{RPCResult::Type::NUM, "networkhashps", "The network hashes per second"},
433+
{RPCResult::Type::NUM, "difficulty", /*optional=*/true, "The current difficulty"},
434+
{RPCResult::Type::NUM, "networkhashps", /*optional=*/true, "The network hashes per second"},
435435
{RPCResult::Type::NUM, "pooledtx", "The size of the mempool"},
436436
{RPCResult::Type::STR, "chain", "current network name (main, test, signet, regtest)"},
437437
{RPCResult::Type::STR, "warnings", "any network and blockchain warnings"},

src/rpc/node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static RPCHelpMan getpakinfo()
481481
RPCResult{
482482
RPCResult::Type::OBJ, "", "",
483483
{
484-
{RPCResult::Type::ARR, "block_paklist", "The PAK list loaded from latest epoch",
484+
{RPCResult::Type::OBJ, "block_paklist", "The PAK list loaded from latest epoch",
485485
{
486486
{RPCResult::Type::ELISION, "", ""}
487487
}},

src/rpc/output_script.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ static RPCHelpMan validateaddress()
4444
{RPCResult::Type::BOOL, "iswitness", /*optional=*/true, "If the address is a witness address"},
4545
{RPCResult::Type::NUM, "witness_version", /*optional=*/true, "The version number of the witness program"},
4646
{RPCResult::Type::STR_HEX, "witness_program", /*optional=*/true, "The hex value of the witness program"},
47-
{RPCResult::Type::STR_HEX, "confidential_key", "the raw blinding public key for that address, if any. \"\" if none"},
48-
{RPCResult::Type::STR, "unconfidential", "The address without confidentiality key"},
47+
{RPCResult::Type::STR_HEX, "confidential_key", /*optional=*/true, "the raw blinding public key for that address, if any. \"\" if none"},
48+
{RPCResult::Type::STR, "unconfidential", /*optional=*/true, "The address without confidentiality key"},
4949
{RPCResult::Type::OBJ, "parent_address_info", /*optional=*/true, "If the address isvalid_parent, this object contains details about the parent address type",
5050
{
5151
{RPCResult::Type::STR, "address", ""},
52-
{RPCResult::Type::STR_HEX, "scriptPubKey", ""},
52+
{RPCResult::Type::STR_HEX, "scriptPubKey", "The hex-encoded scriptPubKey generated by the address"},
53+
{RPCResult::Type::STR_HEX, "confidential_key", "The raw blinding public key for that address, if any. \"\" if none"},
54+
{RPCResult::Type::STR_HEX, "unconfidential", "The address without confidentiality key"},
55+
{RPCResult::Type::BOOL, "isscript", "If the key is a script"},
56+
{RPCResult::Type::BOOL, "iswitness", "If the address is a witness address"},
57+
{RPCResult::Type::NUM, "witness_version", /*optional=*/true, "The version number of the witness program"},
58+
{RPCResult::Type::STR_HEX, "witness_program", /*optional=*/true, "The hex value of the witness program"},
5359
}},
5460
{RPCResult::Type::STR, "error", /*optional=*/true, "Error message, if any"},
5561
{RPCResult::Type::STR, "error_parent", /* optional */ true, "Error message, if any"},

0 commit comments

Comments
 (0)