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

Return all available information via RPC call "validateaddress" #6262

Merged
merged 1 commit into from Jun 19, 2015

Conversation

Projects
None yet
4 participants
@dexX7
Contributor

dexX7 commented Jun 9, 2015

"validateaddress" omits some information, even in cases where it's available.

The primary motivation is to be able to retrieve redeemScripts, after using "addmultisigaddress", when not all keys are available, but the redeemScripts actually are.

The output of "validateaddress" with this PR:

Keys not available:

validateaddress "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3"
{
  "isvalid": true,
  "address": "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3",
  "scriptPubKey": "76a914fa20d564550b105787f7ce3a9ad7fd9a45cd407088ac",
  "ismine": false,
  "iswatchonly": false,
  "isscript": false
}
validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK"
{
  "isvalid": true,
  "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK",
  "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187",
  "ismine": false,
  "iswatchonly": false,
  "isscript": true
}

After adding the redeemScript:

addmultisigaddress 2 '["02537357B156A33306A7A014A3748631C59DF405B56F11BA4AA4A3CE81501AF095","02F1FB200390E7864EF4450C07B15988179A57C3CF3A878F668E1070CB615749FE"]'
2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK
validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK"
{
  "isvalid": true,
  "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK",
  "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187",
  "ismine": false,
  "iswatchonly": false,
  "isscript": true,
  "script": "multisig",
  "hex": "522102537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af0952102f1fb200390e7864ef4450c07b15988179a57c3cf3a878f668e1070cb615749fe52ae",
  "addresses": [
    "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3",
    "mmSKNtbYYHRrhTLKiok5TuYrGEs4Y2A4k6"
  ],
  "sigsrequired": 2,
  "account": ""
}

All keys available:

importprivkey "cR47hEvnsFhF4WNG1E69tvVYEwqeEgW51WGJEJimxRyH8EajqBUE"
importprivkey "cQnVk2cdUT6Kqg5kFAz1jXQVB1ksy9eBSMJzGXE8Ka7xBjwqarTB"
validateaddress "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3"
{
  "isvalid": true,
  "address": "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3",
  "scriptPubKey": "76a914fa20d564550b105787f7ce3a9ad7fd9a45cd407088ac",
  "ismine": true,
  "iswatchonly": false,
  "isscript": false,
  "pubkey": "02537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af095",
  "iscompressed": true,
  "account": ""
}
validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK"
{
  "isvalid": true,
  "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK",
  "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187",
  "ismine": true,
  "iswatchonly": false,
  "isscript": true,
  "script": "multisig",
  "hex": "522102537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af0952102f1fb200390e7864ef4450c07b15988179a57c3cf3a878f668e1070cb615749fe52ae",
  "addresses": [
    "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3",
    "mmSKNtbYYHRrhTLKiok5TuYrGEs4Y2A4k6"
  ],
  "sigsrequired": 2,
  "account": ""
}
Return all available information via validateaddress
`"validateaddress"` omits some information, even in cases where is it available.

The primary motivation is to be able to retrieve redeemScripts, after using `"addmultisigaddress"`, when not all keys are available in the keystore, but the redeemScript actually is.

The output of `"validateaddress"` with this commit:

Keys not available:
```js
validateaddress "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3"
{
  "isvalid": true,
  "address": "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3",
  "scriptPubKey": "76a914fa20d564550b105787f7ce3a9ad7fd9a45cd407088ac",
  "ismine": false,
  "iswatchonly": false,
  "isscript": false
}
```
```js
validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK"
{
  "isvalid": true,
  "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK",
  "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187",
  "ismine": false,
  "iswatchonly": false,
  "isscript": true
}
```

After adding the redeemScript:
```js
addmultisigaddress 2 '["02537357B156A33306A7A014A3748631C59DF405B56F11BA4AA4A3CE81501AF095","02F1FB200390E7864EF4450C07B15988179A57C3CF3A878F668E1070CB615749FE"]'
2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK

validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK"
{
  "isvalid": true,
  "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK",
  "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187",
  "ismine": false,
  "iswatchonly": false,
  "isscript": true,
  "script": "multisig",
  "hex": "522102537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af0952102f1fb200390e7864ef4450c07b15988179a57c3cf3a878f668e1070cb615749fe52ae",
  "addresses": [
    "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3",
    "mmSKNtbYYHRrhTLKiok5TuYrGEs4Y2A4k6"
  ],
  "sigsrequired": 2,
  "account": ""
}
```

All keys available:
```js
validateaddress "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3"
{
  "isvalid": true,
  "address": "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3",
  "scriptPubKey": "76a914fa20d564550b105787f7ce3a9ad7fd9a45cd407088ac",
  "ismine": true,
  "iswatchonly": false,
  "isscript": false,
  "pubkey": "02537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af095",
  "iscompressed": true,
  "account": ""
}
```
```js
validateaddress "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK"
{
  "isvalid": true,
  "address": "2N2g2H7gjA8a11g1yKBgh5VTqndyvbnWpBK",
  "scriptPubKey": "a9146769c19a16c9400b908756e19a4d2afb9e9760e187",
  "ismine": true,
  "iswatchonly": false,
  "isscript": true,
  "script": "multisig",
  "hex": "522102537357b156a33306a7a014a3748631c59df405b56f11ba4aa4a3ce81501af0952102f1fb200390e7864ef4450c07b15988179a57c3cf3a878f668e1070cb615749fe52ae",
  "addresses": [
    "n4KWZKx349gdMQGgTnZ8W6WfgSwybkGSK3",
    "mmSKNtbYYHRrhTLKiok5TuYrGEs4Y2A4k6"
  ],
  "sigsrequired": 2,
  "account": ""
}
```

@laanwj laanwj added the RPC/REST/ZMQ label Jun 9, 2015

@jonasschnelli

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli
Member

jonasschnelli commented Jun 11, 2015

utACK

@laanwj laanwj added the Feature label Jun 15, 2015

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa Jun 16, 2015

Member

utACK

Member

sipa commented Jun 16, 2015

utACK

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jun 19, 2015

Member

Invalid address

$ src/bitcoin-cli validateaddress msj42CCGruhRsFrGATiUuh25dtxYtnpbT
{
  "isvalid": false
}

Valid, own address

src/bitcoin-cli validateaddress msj42CCGruhRsFrGATiUuh25dtxYtnpbTx
{
  "isvalid": true,
  "address": "msj42CCGruhRsFrGATiUuh25dtxYtnpbTx",
  "scriptPubKey": "76a91485eb47fe98f349065d6f044e27a4ac541af79ee288ac",
  "ismine": false,
  "iswatchonly": false,
  "isscript": false
}

Valid, non-own address

$ src/bitcoin-cli validateaddress mpGLz2gJcVG75xgbwMVDXmruBBpuRRL9KQ
{
  "isvalid": true,
  "address": "mpGLz2gJcVG75xgbwMVDXmruBBpuRRL9KQ",
  "scriptPubKey": "76a9145ff5d5286bd5c904f20935ff45cf59d865c745fd88ac",
  "ismine": false,
  "iswatchonly": false,
  "isscript": false
}

Imported watchonly address

$ src/bitcoin-cli validateaddress mys3A1gFacVkCsCC1yw2GiASeDpjLXv1Cr
{
  "isvalid": true,
  "address": "mys3A1gFacVkCsCC1yw2GiASeDpjLXv1Cr",
  "scriptPubKey": "76a914c93ea43293ecfbb3acffba423f0d85cf78d6a10e88ac",
  "ismine": false,
  "iswatchonly": true,
  "isscript": false,
  "account": ""
}

ACK

Member

laanwj commented Jun 19, 2015

Invalid address

$ src/bitcoin-cli validateaddress msj42CCGruhRsFrGATiUuh25dtxYtnpbT
{
  "isvalid": false
}

Valid, own address

src/bitcoin-cli validateaddress msj42CCGruhRsFrGATiUuh25dtxYtnpbTx
{
  "isvalid": true,
  "address": "msj42CCGruhRsFrGATiUuh25dtxYtnpbTx",
  "scriptPubKey": "76a91485eb47fe98f349065d6f044e27a4ac541af79ee288ac",
  "ismine": false,
  "iswatchonly": false,
  "isscript": false
}

Valid, non-own address

$ src/bitcoin-cli validateaddress mpGLz2gJcVG75xgbwMVDXmruBBpuRRL9KQ
{
  "isvalid": true,
  "address": "mpGLz2gJcVG75xgbwMVDXmruBBpuRRL9KQ",
  "scriptPubKey": "76a9145ff5d5286bd5c904f20935ff45cf59d865c745fd88ac",
  "ismine": false,
  "iswatchonly": false,
  "isscript": false
}

Imported watchonly address

$ src/bitcoin-cli validateaddress mys3A1gFacVkCsCC1yw2GiASeDpjLXv1Cr
{
  "isvalid": true,
  "address": "mys3A1gFacVkCsCC1yw2GiASeDpjLXv1Cr",
  "scriptPubKey": "76a914c93ea43293ecfbb3acffba423f0d85cf78d6a10e88ac",
  "ismine": false,
  "iswatchonly": true,
  "isscript": false,
  "account": ""
}

ACK

@laanwj laanwj merged commit 506bae3 into bitcoin:master Jun 19, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Jun 19, 2015

Merge pull request #6262
506bae3 Return all available information via validateaddress (dexX7)

@str4d str4d referenced this pull request Feb 14, 2017

Merged

Bitcoin 0.12 RPC PRs 1 #2100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment