Skip to content
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

jsonrpc: Return more info for validateaddress. #2096

Merged
merged 2 commits into from Dec 21, 2021

Conversation

JoeGruffins
Copy link
Member

Add addressn, branch, and index returns so that a caller can determine
the HD path of an address when applicable. Also return more data for
not owned addresses when possible.

closes #2074

rpc/walletrpc/api.pb.go Outdated Show resolved Hide resolved
@JoeGruffins JoeGruffins force-pushed the rpchdpath branch 2 times, most recently from 5209193 to 73a4d2a Compare December 21, 2021 04:29
@JoeGruffins
Copy link
Member Author

JoeGruffins commented Dec 21, 2021

master
{
  "isvalid": false
}
{
  "isvalid": true,
  "address": "TkKkYvSrnu8orwhtedcJGkD7guarvZUbUAtjr4iKqD9Y8pNEf8iHu"
}
{
  "isvalid": true,
  "address": "Tsp18L8qTcjzigYXrD5GSdwDmhVYBpKmfUL"
}
{
  "isvalid": true,
  "address": "TkKnVfd6EvzEYAqiELWstkASHgVyYH8JK3gNvAxUX79C9CrnsV8W6"
}
{
  "isvalid": true,
  "address": "Tead9n1wLBgaUR7AZrrtt6WWeDfetbF3dpy"
}
{
  "isvalid": true,
  "address": "TkKpSQoKgxqfDPyXp3RTWk7ktTR69zn19vU1zHCdD18r9bMTvDKT3"
}
{
  "isvalid": true,
  "address": "TSs3jHQMbbZGPyftUh4cgaALzgDZhfXGtxn"
}
{
  "isvalid": true,
  "address": "TcvVou7ooM4rJRWNeJYwehJ9fQq1HTc5pbK"
}
{
  "isvalid": true,
  "address": "TkKkYvSrnu8orwhtedcJGkD7guarvZUbUAtjr4iKqD9Y8pNEf8iHu"
}
{
  "isvalid": true,
  "address": "TcfdqCrK2fiFJBZnGj5N6xs6rMsbQBsJBYf",
  "ismine": true,
  "isscript": true,
  "account": "imported",
  "addresses": [
    "Tsk7YBwMxAko9edC2EL4JfootfCZewErWJF"
  ],
  "hex": "c376a914d17043c104a57393aa7353e1510e39eab811e3db88ac",
  "script": "treasurygen-pubkeyhash"
}
{
  "isvalid": true,
  "address": "TcrzaAVMbFURm1PpukWru8yE2uBTjvQePoa",
  "ismine": true,
  "isscript": true,
  "account": "imported",
  "addresses": [
    "TkQ4yoYbKYRzu89ufDNqC3fnxvn82wFTUgbF1xdgMpmmqGU8sYKFx",
    "TkQ3saYQz1423EiRAST9Lj9UWp3UJT9q6JvZLmao2HSSjG1v2Lp4G"
  ],
  "hex": "522103d484eb60ad03549e731ae9045281f8ee14ff6ea11b697f32cde3d8a18992261b210342b0b9c0ecb53cb9761beb0d010bbf08b5049d2a4d3bea5d3a1d95eb664931cb52ae",
  "script": "multisig",
  "sigsrequired": 2
}
{
  "isvalid": true,
  "address": "TckSpBht36nMZgnDDjv7xaHUrgCyJpxQiLA",
  "ismine": true,
  "isscript": true,
  "account": "imported",
  "hex": "01",
  "script": "nonstandard"
}
{
  "isvalid": true,
  "address": "Tsd5gT95ezpcqp1M3mNe9r113zb8dURsebs",
  "ismine": true,
  "pubkeyaddr": "TkQ3NkMGY3xd8p133Pk4BsHv6MyoexjSfC5nnHdKHvrWS1sbqfXnq",
  "pubkey": "030139eb89b3c36f39f95e4630c0e7f6cc3fef62db56592b15bc475366d5822b29",
  "iscompressed": true,
  "account": "default"
}
this pr currently
{
  "isvalid": false,
  "script": "nonstandard"
}
{
  "isvalid": true,
  "address": "TkKkYvSrnu8orwhtedcJGkD7guarvZUbUAtjr4iKqD9Y8pNEf8iHu",
  "pubkeyaddr": "TkKkYvSrnu8orwhtedcJGkD7guarvZUbUAtjr4iKqD9Y8pNEf8iHu",
  "pubkey": "020000000000000000000000000000000000000000000000000000000000000001",
  "script": "pubkey"
}
{
  "isvalid": true,
  "address": "Tsp18L8qTcjzigYXrD5GSdwDmhVYBpKmfUL",
  "iscompressed": true,
  "script": "pubkeyhash"
}
{
  "isvalid": true,
  "address": "TkKnVfd6EvzEYAqiELWstkASHgVyYH8JK3gNvAxUX79C9CrnsV8W6",
  "pubkeyaddr": "TkKnVfd6EvzEYAqiELWstkASHgVyYH8JK3gNvAxUX79C9CrnsV8W6",
  "pubkey": "0000000000000000000000000000000000000000000000000000000000000000",
  "script": "pubkey-ed25519"
}
{
  "isvalid": true,
  "address": "Tead9n1wLBgaUR7AZrrtt6WWeDfetbF3dpy",
  "iscompressed": true,
  "script": "pubkeyhash-ed25519"
}
{
  "isvalid": true,
  "address": "TkKpSQoKgxqfDPyXp3RTWk7ktTR69zn19vU1zHCdD18r9bMTvDKT3",
  "pubkeyaddr": "TkKpSQoKgxqfDPyXp3RTWk7ktTR69zn19vU1zHCdD18r9bMTvDKT3",
  "pubkey": "020000000000000000000000000000000000000000000000000000000000000001",
  "script": "pubkey-schnorr-secp256k1"
}
{
  "isvalid": true,
  "address": "TSs3jHQMbbZGPyftUh4cgaALzgDZhfXGtxn",
  "iscompressed": true,
  "script": "pubkeyhash-schnorr-secp256k1"
}
{
  "isvalid": true,
  "address": "TcvVou7ooM4rJRWNeJYwehJ9fQq1HTc5pbK",
  "isscript": true,
  "iscompressed": true,
  "script": "scripthash"
}
{
  "isvalid": true,
  "address": "TkKkYvSrnu8orwhtedcJGkD7guarvZUbUAtjr4iKqD9Y8pNEf8iHu",
  "pubkeyaddr": "TkKkYvSrnu8orwhtedcJGkD7guarvZUbUAtjr4iKqD9Y8pNEf8iHu",
  "pubkey": "020000000000000000000000000000000000000000000000000000000000000001",
  "script": "pubkey"
}
{
  "isvalid": true,
  "address": "TcfdqCrK2fiFJBZnGj5N6xs6rMsbQBsJBYf",
  "ismine": true,
  "isscript": true,
  "iscompressed": true,
  "account": "imported",
  "addresses": [
    "Tsk7YBwMxAko9edC2EL4JfootfCZewErWJF"
  ],
  "hex": "c376a914d17043c104a57393aa7353e1510e39eab811e3db88ac",
  "script": "treasurygen-pubkeyhash"
}
{
  "isvalid": true,
  "address": "TcrzaAVMbFURm1PpukWru8yE2uBTjvQePoa",
  "ismine": true,
  "isscript": true,
  "iscompressed": true,
  "account": "imported",
  "addresses": [
    "TkQ4yoYbKYRzu89ufDNqC3fnxvn82wFTUgbF1xdgMpmmqGU8sYKFx",
    "TkQ3saYQz1423EiRAST9Lj9UWp3UJT9q6JvZLmao2HSSjG1v2Lp4G"
  ],
  "hex": "522103d484eb60ad03549e731ae9045281f8ee14ff6ea11b697f32cde3d8a18992261b210342b0b9c0ecb53cb9761beb0d010bbf08b5049d2a4d3bea5d3a1d95eb664931cb52ae",
  "script": "multisig",
  "sigsrequired": 2
}
{
  "isvalid": true,
  "address": "TckSpBht36nMZgnDDjv7xaHUrgCyJpxQiLA",
  "ismine": true,
  "isscript": true,
  "iscompressed": true,
  "account": "imported",
  "hex": "01",
  "script": "nonstandard"
}
{
  "isvalid": true,
  "address": "TsfWQ6ocycevDFJu7A1JyBzxEu7M6ppW5Un",
  "ismine": true,
  "pubkeyaddr": "TkKkmUnuTQBsU5n99f9GsZPRRtxexvaMtbTgMuzv1RKPL4UGXjbd3",
  "pubkey": "021c83857e15870e77d4f2855886edc188f98f85b5f093d813a44a25461c717855",
  "iscompressed": true,
  "account": "default",
  "script": "pubkeyhash",
  "accountn": 0,
  "branch": 0,
  "index": 56
}

One subtle change that may or may not be welcome is that "script": "nonstandard" is set for invalid addresses. Not needed?

One thing I think should be changed is that "address" just returns whatever you put in. Because we have the "pubkeyaddr" field separately, it would make more sense to me if a query for a pubkey returned the encoded pubkeyhash address there. Or had a new "pubkeyhash" field, otherwise there is not a simple way to know what it is using rpc commands I beleive.

Add addressn, branch, and index returns so that a caller can determine
the HD path of an address when applicable. Also return more data for
not owned addresses when possible.
@jrick
Copy link
Member

jrick commented Dec 21, 2021

One subtle change that may or may not be welcome is that "script": "nonstandard" is set for invalid addresses. Not needed?

I don't see this as an issue

@jrick jrick merged commit b6a70c5 into decred:master Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON-RPC validateaddress method should show HD derivation path
3 participants