You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge #17283: rpc: improve getaddressinfo test coverage, help, code docs
33f5fc3 test: add rpc getaddressinfo labels test coverage (Jon Atack)
0f3539a test: add listlabels test in wallet_labels.py (Jon Atack)
1388de8 rpc: add getaddressinfo code documentation (Jon Atack)
2ee0cb3 rpc: update getaddressinfo RPCExamples to bech32 (Jon Atack)
8d1ed0c rpc: clarify label vs labels in getaddressinfo RPCHelpman (Jon Atack)
5a0ed85 rpc: improve getaddressinfo RPCHelpman content (Jon Atack)
70cda34 rpc: improve getaddressinfo RPCHelpman formatting (Jon Atack)
Pull request description:
This PR is a continuation of the work in bitcoin/bitcoin#12892.
Main motivations:
- There is currently no test coverage for the getaddressinfo `labels` response. Coverage here is a prerequisite before deprecating the `label` response or adding multiple labels per address.
- `bitcoin-cli help getaddressinfo` returns a few content errors, difficult-to-read formatting, and no explanation why it returns both `label` and `labels` and how they relate, which can be confusing for application developers.
Changes by order of commits:
- [x] improve/fix getaddressinfo RPCHelpman layout formatting
- [x] improve/fix getaddressinfo RPCHelpman content
- [x] clarify the `label` and `labels` fields in getaddressinfo RPCHelpman
- [x] update getaddressinfo RPCExamples addresses to bech32
- [x] add getaddressinfo code docs
- [x] add a `listlabels` test assertion in wallet_labels.py
- [x] add missing getaddressinfo `labels` test coverage and improve the existing `label` tests
Here are gists of the CLI help output:
[`bitcoin-cli help getaddressinfo` before this PR](https://gist.github.com/jonatack/022af5221a85c069780359a22643c810)
[`bitcoin-cli help getaddressinfo` after this PR](https://gist.github.com/jonatack/4ee5f6abc62a3d99269570206a5f90ba)
It seems we ought to begin a deprecation process for the getaddressinfo `label` field? If yes, I have a follow-up ready. _--> EDIT: Deprecation follow-ups #17578 and #17585 now build on this PR._
ACKs for top commit:
fjahr:
Re-ACK 33f5fc3
jnewbery:
ACK 33f5fc3.
Tree-SHA512: a001aa863090ec2566a31059477945b1c303ebeb430b33472f8b150e420fa5742fc33bca9d95571746395b607f43f6078dd5b53e238ac1f3fc648b51c8f79a07
"\nReturn information about the given bitcoin address. Some information requires the address\n"
3713
-
"to be in the wallet.\n",
3712
+
"\nReturn information about the given bitcoin address.\n"
3713
+
"Some of the information will only be present if the address is in the active wallet.\n",
3714
3714
{
3715
-
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to get the information of."},
3715
+
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address for which to get information."},
3716
3716
},
3717
3717
RPCResult{
3718
3718
"{\n"
3719
-
"\"address\" : \"address\", (string) The bitcoin address validated\n"
3720
-
"\"scriptPubKey\" : \"hex\", (string) The hex-encoded scriptPubKey generated by the address\n"
3721
-
"\"ismine\" : true|false, (boolean) If the address is yours or not\n"
3722
-
"\"iswatchonly\" : true|false, (boolean) If the address is watchonly\n"
3723
-
"\"solvable\" : true|false, (boolean) Whether we know how to spend coins sent to this address, ignoring the possible lack of private keys\n"
3724
-
"\"desc\" : \"desc\", (string, optional) A descriptor for spending coins sent to this address (only when solvable)\n"
3725
-
"\"isscript\" : true|false, (boolean) If the key is a script\n"
3726
-
"\"ischange\" : true|false, (boolean) If the address was used for change output\n"
3727
-
"\"iswitness\" : true|false, (boolean) If the address is a witness address\n"
3728
-
"\"witness_version\" : version (numeric, optional) The version number of the witness program\n"
3729
-
"\"witness_program\" : \"hex\" (string, optional) The hex value of the witness program\n"
3730
-
"\"script\" : \"type\" (string, optional) The output script type. Only if \"isscript\" is true and the redeemscript is known. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash, witness_unknown\n"
3731
-
"\"hex\" : \"hex\", (string, optional) The redeemscript for the p2sh address\n"
3732
-
"\"pubkeys\" (string, optional) Array of pubkeys associated with the known redeemscript (only if \"script\" is \"multisig\")\n"
3719
+
"\"address\" : \"address\", (string) The bitcoin address validated.\n"
3720
+
"\"scriptPubKey\" : \"hex\", (string) The hex-encoded scriptPubKey generated by the address.\n"
3721
+
"\"ismine\" : true|false, (boolean) If the address is yours.\n"
3722
+
"\"iswatchonly\" : true|false, (boolean) If the address is watchonly.\n"
3723
+
"\"solvable\" : true|false, (boolean) If we know how to spend coins sent to this address, ignoring the possible lack of private keys.\n"
3724
+
"\"desc\" : \"desc\", (string, optional) A descriptor for spending coins sent to this address (only when solvable).\n"
3725
+
"\"isscript\" : true|false, (boolean) If the key is a script.\n"
3726
+
"\"ischange\" : true|false, (boolean) If the address was used for change output.\n"
3727
+
"\"iswitness\" : true|false, (boolean) If the address is a witness address.\n"
3728
+
"\"witness_version\" : version (numeric, optional) The version number of the witness program.\n"
3729
+
"\"witness_program\" : \"hex\" (string, optional) The hex value of the witness program.\n"
3730
+
"\"script\" : \"type\" (string, optional) The output script type. Only if isscript is true and the redeemscript is known. Possible\n"
"\"hex\" : \"hex\", (string, optional) The redeemscript for the p2sh address.\n"
3734
+
"\"pubkeys\" (array, optional) Array of pubkeys associated with the known redeemscript (only if script is multisig).\n"
3733
3735
" [\n"
3734
-
"\"pubkey\"\n"
3736
+
"\"pubkey\" (string)\n"
3735
3737
" ,...\n"
3736
3738
" ]\n"
3737
-
"\"sigsrequired\" : xxxxx (numeric, optional) Number of signatures required to spend multisig output (only if \"script\" is \"multisig\")\n"
3738
-
"\"pubkey\" : \"publickeyhex\", (string, optional) The hex value of the raw public key, for single-key addresses (possibly embedded in P2SH or P2WSH)\n"
3739
-
"\"embedded\" : {...}, (object, optional) Information about the address embedded in P2SH or P2WSH, if relevant and known. It includes all getaddressinfo output fields for the embedded address, excluding metadata (\"timestamp\", \"hdkeypath\", \"hdseedid\") and relation to the wallet (\"ismine\", \"iswatchonly\").\n"
3740
-
"\"iscompressed\" : true|false, (boolean, optional) If the pubkey is compressed\n"
3741
-
"\"label\" : \"label\" (string) The label associated with the address, \"\" is the default label\n"
3742
-
"\"timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n"
3743
-
"\"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n"
3744
-
"\"hdseedid\" : \"<hash160>\" (string, optional) The Hash160 of the HD seed\n"
3745
-
"\"hdmasterfingerprint\" : \"<hash160>\" (string, optional) The fingperint of the master key.\n"
3746
-
"\"labels\" (object) Array of labels associated with the address.\n"
3739
+
"\"sigsrequired\" : xxxxx (numeric, optional) The number of signatures required to spend multisig output (only if script is multisig).\n"
3740
+
"\"pubkey\" : \"publickeyhex\", (string, optional) The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH).\n"
3741
+
"\"embedded\" : {...}, (object, optional) Information about the address embedded in P2SH or P2WSH, if relevant and known. Includes all\n"
3742
+
" getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath,\n"
3743
+
" hdseedid) and relation to the wallet (ismine, iswatchonly).\n"
3744
+
"\"iscompressed\" : true|false, (boolean, optional) If the pubkey is compressed.\n"
3745
+
"\"label\" : \"label\" (string) The label associated with the address. Defaults to \"\". Equivalent to the name field in the labels array.\n"
3746
+
"\"timestamp\" : timestamp, (number, optional) The creation time of the key if available, expressed in seconds since Epoch Time (Jan 1 1970 GMT).\n"
3747
+
"\"hdkeypath\" : \"keypath\" (string, optional) The HD keypath, if the key is HD and available.\n"
3748
+
"\"hdseedid\" : \"<hash160>\" (string, optional) The Hash160 of the HD seed.\n"
3749
+
"\"hdmasterfingerprint\" : \"<hash160>\" (string, optional) The fingerprint of the master key.\n"
3750
+
"\"labels\" (object) An array of labels associated with the address. Currently limited to one label but returned\n"
3751
+
" as an array to keep the API stable if multiple labels are enabled in the future.\n"
3747
3752
" [\n"
3748
3753
" { (json object of label data)\n"
3749
-
"\"name\": \"labelname\" (string) The label\n"
3750
-
"\"purpose\": \"string\" (string) Purpose of address (\"send\" for sending address, \"receive\" for receiving address)\n"
3754
+
"\"name\": \"label name\" (string) The label name. Defaults to \"\". Equivalent to the label field above.\n"
3755
+
"\"purpose\": \"purpose\" (string) The purpose of the associated address (send or receive).\n"
0 commit comments