ValidateAddress/验证地址有效性
validateaddress
调用返回指定比特币地址的相关信息。
参数
- Address:地址
返回值
validateaddress
调用返回关于指定地址的信息,其结构如下:
- isvalid:是否有效
- address:地址
- scriptPubKey:公钥脚本
- ismine:是否属于节点钱包
- iswatchonly:是否watch-only地址
- isscript:是否P2SH地址
- script:P2SH地址的赎回脚本类型,可以是:
- pubkey:P2PK脚本
- pubkeyhash:P2PKH脚本
- multisig:多重签名脚本
- nonstandard:非标脚本
- pubkey:P2PK脚本
- hex:P2SH地址对应的赎回脚本,仅对P2SH地址有效
- addresses:P2SH脚本使用的地址数组
- sigrequired:P2SH脚本需要的签名数量
- pubkey:地址对应的公钥
- iscompressed:公钥是否压缩格式
- account:关联的钱包账户
- hdkeypath:层级确定性密钥路径
- hdmasterkeyid:层级确定性主密钥id
示例代码
下面的命令验证一个P2PKH地址:
~$ bitcoin-cli validateaddress 17fshh33qUze2yifiJ2sXgijSMzJ2KNEwu
输出结果如下:
{
"isvalid": true,
"address": "17fshh33qUze2yifiJ2sXgijSMzJ2KNEwu",
"scriptPubKey": "76a914492ae280d70af33acf0ae7cd329b961e65e9cbd888ac",
"ismine": true,
"iswatchonly": false,
"isscript": false,
"pubkey": "0312eeb9ae5f14c3cf43cece11134af860c2ef7d775060e3a578ceec888acada31",
"iscompressed": true,
"account": "Test"
}
下面的命令验证一个多重签名的P2SH地址:
~$ bitcoin-cli -testnet validateaddress 2MyVxxgNBk5zHRPRY2iVjGRJHYZEp1pMCSq
输出结果如下:
{
"isvalid" : true,
"address" : "2MyVxxgNBk5zHRPRY2iVjGRJHYZEp1pMCSq",
"ismine" : true,
"iswatchonly" : false,
"isscript" : true,
"script" : "multisig",
"hex" : "522103ede722780d27b05f0b1169efc90fa15a601a32fc6c3295114500c586831b6aaf2102ecd2d250a76d204011de6bc365a56033b9b3a149f679bc17205555d3c2b2854f21022d609d2f0d359e5bc0e5d0ea20ff9f5d3396cb5b1906aa9c56a0e7b5edc0c5d553ae",
"addresses" : [
"mjbLRSidW1MY8oubvs4SMEnHNFXxCcoehQ",
"mo1vzGwCzWqteip29vGWWW6MsEBREuzW94",
"mt17cV37fBqZsnMmrHnGCm9pM28R1kQdMG"
],
"sigsrequired" : 2,
"account" : "test account"
}