New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPCHelpMan: Check default values are given at compile-time #14918
Conversation
fa4381d
to
faf4ab5
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
faf4ab5
to
fa3292c
Compare
fa9f5a3
to
faff487
Compare
faff487
to
faa60e7
Compare
fafd087
to
2758c66
Compare
2758c66
to
fa8903a
Compare
fa8903a
to
fa46ada
Compare
fa46ada
to
fa5d914
Compare
fa5d914
to
aaaaaeb
Compare
fa4f46e
to
fa63bea
Compare
fa63bea
to
faec234
Compare
faec234
to
fa0ad4e
Compare
@ryanofsky Mind to take a look here? You requested this in #14877 (review) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK fa0ad4e
@ryanofsky Mind to take a look here? You requested this in #14877 (review)
This is a big monster change, but it does make things clearer. I reviewed the code and also diffed the output using #14726 (review). All the changes looked like improvements.
Output
@@ -59,7 +59,7 @@
"key", (string) bitcoin address or hex-encoded public key
...
]
-3. label (string, optional, default=null) A label to assign the addresses to.
+3. label (string, optional) A label to assign the addresses to.
4. address_type (string, optional, default=set by -addresstype) The address type to use. Options are "legacy", "p2sh-segwit", and "bech32".
Result:
@@ -121,7 +121,7 @@
Arguments:
1. txid (string, required) The txid to be bumped
-2. options (json object, optional, default=null)
+2. options (json object, optional)
{
"confTarget": n, (numeric, optional, default=fallback to wallet's default) Confirmation target (in blocks)
"totalFee": n, (numeric, optional, default=fallback to 'confTarget') Total fee (NOT feerate) to pay, in satoshis.
@@ -782,7 +782,7 @@
Arguments:
1. hexstring (string, required) The hex string of the raw transaction
-2. options (json object, optional, default=null) for backward compatibility: passing in a true instead of an object will result in {"includeWatching":true}
+2. options (json object, optional) for backward compatibility: passing in a true instead of an object will result in {"includeWatching":true}
{
"changeAddress": "str", (string, optional, default=pool address) The bitcoin address to receive the change
"changePosition": n, (numeric, optional, default=random) The index of the change output
@@ -972,7 +972,7 @@
thus affected by options which limit spendability such as -spendzeroconfchange.
Arguments:
-1. dummy (string, optional, default=null) Remains for backward compatibility. Must be excluded or set to "*".
+1. dummy (string, optional) Remains for backward compatibility. Must be excluded or set to "*".
2. minconf (numeric, optional, default=0) Only include transactions confirmed at least this many times.
3. include_watchonly (boolean, optional, default=false) Also include balance in watch-only addresses (see 'importaddress')
@@ -1682,7 +1682,7 @@
so payments received with the address will be associated with 'label'.
Arguments:
-1. label (string, optional, default=null) The label name for the address to be linked to. If not provided, the default label "" is used. It can also be set to the empty string "" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name.
+1. label (string, optional, default="") The label name for the address to be linked to. It can also be set to the empty string "" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name.
2. address_type (string, optional, default=set by -addresstype) The address type to use. Options are "legacy", "p2sh-segwit", and "bech32".
Result:
@@ -1859,7 +1859,7 @@
Arguments:
1. txid (string, required) The transaction id
2. verbose (boolean, optional, default=false) If false, return a string, otherwise return a json object
-3. blockhash (string, optional, default=null) The block in which to look for the transaction
+3. blockhash (string, optional) The block in which to look for the transaction
Result (if verbose is not set or set to false):
"data" (string) The serialized, hex-encoded data for 'txid'
@@ -2080,7 +2080,7 @@
"txid", (string) A transaction hash
...
]
-2. blockhash (string, optional, default=null) If specified, looks for txid in the block with this hash
+2. blockhash (string, optional) If specified, looks for txid in the block with this hash
Result:
"data" (string) A string that is a serialized, hex-encoded data for the proof.
@@ -2191,7 +2191,7 @@
1. requests (json array, required) Data to be imported
[
{ (json object)
- "desc": "str", (string, optional) Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys
+ "desc": "str", (string) Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys
"scriptPubKey": "<script>" | { "address":"<address>" }, (string / json, required) Type of scriptPubKey (string for script, json for address). Should not be provided if using a descriptor
"timestamp": timestamp | "now", (integer / string, required) Creation time of the key in seconds since epoch (Jan 1 1970 GMT),
or the string "now" to substitute the current synced blockchain time. The timestamp of the oldest
@@ -2199,8 +2199,8 @@
"now" can be specified to bypass scanning, for keys which are known to never have been used, and
0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest key
creation time of all keys being imported by the importmulti call will be scanned.
- "redeemscript": "str", (string, optional, default=omitted) Allowed only if the scriptPubKey is a P2SH or P2SH-P2WSH address/scriptPubKey
- "witnessscript": "str", (string, optional, default=omitted) Allowed only if the scriptPubKey is a P2SH-P2WSH or P2WSH address/scriptPubKey
+ "redeemscript": "str", (string) Allowed only if the scriptPubKey is a P2SH or P2SH-P2WSH address/scriptPubKey
+ "witnessscript": "str", (string) Allowed only if the scriptPubKey is a P2SH-P2WSH or P2WSH address/scriptPubKey
"pubkeys": [ (json array, optional, default=empty array) Array of strings giving pubkeys to import. They must occur in P2PKH or P2WPKH scripts. They are not required when the private key is also provided (see the "keys" argument).
"pubKey", (string)
...
@@ -2209,7 +2209,7 @@
"key", (string)
...
],
- { (json object, optional) If a ranged descriptor is used, this specifies the start and end of the range to import
+ { (json object) If a ranged descriptor is used, this specifies the start and end of the range to import
"start": n, (numeric, optional, default=0) Start of the range to import
"end": n, (numeric, required) End of the range to import (inclusive)
},
@@ -2219,7 +2219,7 @@
},
...
]
-2. options (json object, optional, default=null)
+2. options (json object, optional)
{
"rescan": bool, (boolean, optional, default=true) Stating if should rescan the blockchain after all imports
}
@@ -2379,7 +2379,7 @@
Returns the list of all labels, or labels that are assigned to addresses with a specific purpose.
Arguments:
-1. purpose (string, optional, default=null) Address purpose to list labels for ('send','receive'). An empty string is the same as not providing this argument.
+1. purpose (string, optional) Address purpose to list labels for ('send','receive'). An empty string is the same as not providing this argument.
Result:
[ (json array of string)
@@ -2442,7 +2442,7 @@
1. minconf (numeric, optional, default=1) The minimum number of confirmations before payments are included.
2. include_empty (boolean, optional, default=false) Whether to include addresses that haven't received any payments.
3. include_watchonly (boolean, optional, default=false) Whether to include watch-only addresses (see 'importaddress').
-4. address_filter (string, optional, default=null) If present, only return information on this address.
+4. address_filter (string, optional) If present, only return information on this address.
Result:
[
@@ -2500,7 +2500,7 @@
Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the "removed" array.
Arguments:
-1. blockhash (string, optional, default=null) If set, the block hash to list transactions since, otherwise list all transactions.
+1. blockhash (string, optional) If set, the block hash to list transactions since, otherwise list all transactions.
2. target_confirmations (numeric, optional, default=1) Return the nth block hash from the main chain. e.g. 1 would mean the best block hash. Note: this is not used as a filter, but only affects [lastblock] in the return value
3. include_watchonly (boolean, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')
4. include_removed (boolean, optional, default=true) Show transactions that were removed due to a reorg in the "removed" array
@@ -2555,7 +2555,7 @@
Returns up to 'count' most recent transactions skipping the first 'from' transactions.
Arguments:
-1. label (string, optional, default=null) If set, should be a valid label name to return only incoming transactions
+1. label (string, optional) If set, should be a valid label name to return only incoming transactions
with the specified label, or "*" to disable filtering and return all transactions.
2. count (numeric, optional, default=10) The number of transactions to return
3. skip (numeric, optional, default=0) The number of transactions to skip
@@ -2622,7 +2622,7 @@
]
4. include_unsafe (boolean, optional, default=true) Include outputs that are not safe to spend
See description of "safe" attribute below.
-5. query_options (json object, optional, default=null) JSON with query options
+5. query_options (json object, optional) JSON with query options
{
"minimumAmount": amount, (numeric or string, optional, default=0) Minimum value of each UTXO in BTC
"maximumAmount": amount, (numeric or string, optional, default=unlimited) Maximum value of each UTXO in BTC
@@ -2766,12 +2766,12 @@
- "none", "0" : even if other logging categories are specified, ignore all of them.
Arguments:
-1. include (json array, optional, default=null) A json array of categories to add debug logging
+1. include (json array, optional) A json array of categories to add debug logging
[
"include_category", (string) the valid logging category
...
]
-2. exclude (json array, optional, default=null) A json array of categories to remove debug logging
+2. exclude (json array, optional) A json array of categories to remove debug logging
[
"exclude_category", (string) the valid logging category
...
@@ -2820,7 +2820,7 @@
Arguments:
1. txid (string, required) The transaction id.
-2. dummy (numeric, optional, default=null) API-Compatibility for previous API. Must be zero or null.
+2. dummy (numeric, optional) API-Compatibility for previous API. Must be zero or null.
DEPRECATED. For forward compatibility use named arguments and omit this parameter.
3. fee_delta (numeric, required) The fee value (in satoshis) to add (or subtract, if negative).
Note, that this value is not a fee rate. It is a value to modify absolute fee of the TX.
@@ -2975,8 +2975,8 @@
"address": amount, (numeric or string, required) The bitcoin address is the key, the numeric amount (can be string) in BTC is the value
}
3. minconf (numeric, optional, default=1) Only use the balance confirmed at least this many times.
-4. comment (string, optional, default=null) A comment
-5. subtractfeefrom (json array, optional, default=null) A json array with addresses.
+4. comment (string, optional) A comment
+5. subtractfeefrom (json array, optional) A json array with addresses.
The fee will be equally deducted from the amount of each selected address.
Those recipients will receive less bitcoins than you enter in their corresponding amount field.
If no addresses are specified here, the sender pays the fee.
@@ -3044,9 +3044,9 @@
Arguments:
1. address (string, required) The bitcoin address to send to.
2. amount (numeric or string, required) The amount in BTC to send. eg 0.1
-3. comment (string, optional, default=null) A comment used to store what the transaction is for.
+3. comment (string, optional) A comment used to store what the transaction is for.
This is not part of the transaction, just kept in your wallet.
-4. comment_to (string, optional, default=null) A comment to store the name of the person or organization
+4. comment_to (string, optional) A comment to store the name of the person or organization
to which you're sending the transaction. This is not part of the
transaction, just kept in your wallet.
5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.
@@ -3217,13 +3217,13 @@
"privatekey", (string) private key in base58-encoding
...
]
-3. prevtxs (json array, optional, default=null) A json array of previous dependent transaction outputs
+3. prevtxs (json array, optional) A json array of previous dependent transaction outputs
[
{ (json object)
"txid": "hex", (string, required) The transaction id
"vout": n, (numeric, required) The output number
"scriptPubKey": "hex", (string, required) script key
- "redeemScript": "hex", (string, optional, default=omitted) (required for P2SH or P2WSH) redeem script
+ "redeemScript": "hex", (string) (required for P2SH or P2WSH) redeem script
"amount": amount, (numeric or string, required) The amount spent
},
...
@@ -3266,13 +3266,13 @@
Arguments:
1. hexstring (string, required) The transaction hex string
-2. prevtxs (json array, optional, default=null) A json array of previous dependent transaction outputs
+2. prevtxs (json array, optional) A json array of previous dependent transaction outputs
[
{ (json object)
"txid": "hex", (string, required) The transaction id
"vout": n, (numeric, required) The output number
"scriptPubKey": "hex", (string, required) script key
- "redeemScript": "hex", (string, optional, default=omitted) (required for P2SH or P2WSH)
+ "redeemScript": "hex", (string) (required for P2SH or P2WSH) redeem script
"amount": amount, (numeric or string, required) The amount spent
},
...
@@ -3586,7 +3586,7 @@
...
]
3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs
-4. options (json object, optional, default=null)
+4. options (json object, optional)
{
"changeAddress": "hex", (string, optional, default=pool address) The bitcoin address to receive the change
"changePosition": n, (numeric, optional, default=random) The index of the change output
/** Required arg */ | ||
NO, | ||
/** | ||
* Optinal arg that is a named argument and has a default value of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling optinal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea.. why was this ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea.. why was this ignored?
Just in order to able to merge the pr quickly (it was big and needed to be rebased a lot). The spelling could be fixed later.
…mpile-time fa0ad4e RPCHelpMan: Check default values are given at compile-time (MarcoFalke) Pull request description: Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time. Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
Summary: This is a backport of Core [[bitcoin/bitcoin#14918 | PR14918]] In order to automate somewhat the process, I used the following commands: ``` sed -n '1h; 1!H; ${ g; s@/\* opt \*/ true,\n \+@/* opt */ true, @g; p}' -i ../src/wallet/rpc*.cpp ../src/rpc/*.cpp sed -n '1h; 1!H; ${ g; s@/\* opt \*/ false,\n \+@/* opt */ false, @g; p}' -i ../src/wallet/rpc*.cpp ../src/rpc/*.cpp sed -e 's@/\* opt \*/ false, /\* default_val \*/ ""@RPCArg::Optional::NO@' -i ../src/wallet/rpc*.cpp ../src/rpc/*.cpp # Manual edit for OMITTED and OMITTED_NAMED_ARG sed -e 's@/\* opt \*/ true, /\* default_val \*/@/* default */@' -i ../src/wallet/rpc*.cpp ../src/rpc/*.cpp ``` Test Plan: ninja all check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D6064
…mpile-time fa0ad4e RPCHelpMan: Check default values are given at compile-time (MarcoFalke) Pull request description: Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time. Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
…mpile-time fa0ad4e RPCHelpMan: Check default values are given at compile-time (MarcoFalke) Pull request description: Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time. Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
…mpile-time fa0ad4e RPCHelpMan: Check default values are given at compile-time (MarcoFalke) Pull request description: Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time. Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
…mpile-time fa0ad4e RPCHelpMan: Check default values are given at compile-time (MarcoFalke) Pull request description: Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time. Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
…mpile-time fa0ad4e RPCHelpMan: Check default values are given at compile-time (MarcoFalke) Pull request description: Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time. Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time.