Bitcoin-Core

如何正確使用 importmulti 和冷卡錢包 BIP84 xpub?

  • June 25, 2019

我已經看過 HWI 腳本,但我正在嘗試這樣做,同時保持我的 Coldcard 氣隙。

首先,我在禁用私鑰的比特幣核心中創建了一個錢包。

我將錢包摘要轉儲到冷卡 SD 卡上並輸出:

# Coldcard Wallet Summary File

## Wallet operates on blockchain: Bitcoin Testnet

For BIP44, this is coin_type '1', and internally we use symbol XTN for this blockchain.

## Top-level, 'master' extended public key ('m/'):

tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY

Derived public keys, as may be needed for different systems:


## For Bitcoin Core: m/{account}'/{change}'/{idx}'

m => tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY

... first 5 receive addresses (account=0, change=0):

m/0'/0'/0' => mwokgDX6HQREsFgevxZwKDxmVfDjEqwPuC
m/0'/0'/1' => mwGmYgnd3MDjaTXfp5dgq5YxNtGjfRyTuT
m/0'/0'/2' => mntHLuyhXr6QsVsWstRs3XFHaMXD8AKuLo
m/0'/0'/3' => msU7yGFgbqTJF9n55jYB8e3Hxh4hi7vhhF
m/0'/0'/4' => mjdKAoMcyieEwcscdvrnKzqu4r6bnfQMj1


## For Bitcoin Core (Segregated Witness, P2PKH): m/{account}'/{change}'/{idx}'

m => tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY
# SLIP-132 style
m => vpub5SLqN2bLY4WeZixKds1JXa6Kn4sdmFU5yb6VgScU4mgMPuB7io2wF3FoLwWX4f5CMpbNPKC7b9VGCpmBDHVob4esrb2THH9VV4jmqZ4QqHz

... first 5 receive addresses (account=0, change=0):

m/0'/0'/0' => tb1qk2hk9sdh0akzyc99nx65a2erpuftcek3v4mret
m/0'/0'/1' => tb1q4nfn0gme6yr9fezwlrdzdycfpztswal0j4l38m
m/0'/0'/2' => tb1q2rgcg659h4fte2c6dzljzskyjz5qfftrfwcyv7
m/0'/0'/3' => tb1qsvv9dv4g7uepe5pk0tf3cp7hdgnmtx5hp626ap
m/0'/0'/4' => tb1q952xefka88ep3s8htxgnw0n60a4spqwfppm5mu


## For Electrum (not BIP44): m/{change}/{idx}

m => tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY

... first 5 receive addresses (account=0, change=0):

m/0/0 => mu7NuiLq1PsK7ncvE5cN3YPwU89wCjz4fC
m/0/1 => mvSCNC4w9wBRksZwQsLPL4pyNMbHB8rFKy
m/0/2 => mooEuT4TzKte4yvNxk4T7Du9K9vG1ZfjyK
m/0/3 => mpuSJdR1W3WLEH1FN3KN3Mxye9dBnnJYd6
m/0/4 => miwaFWAkjmAggdFGix4SGiSxaq4zzue78B


## For BIP44 / Electrum: m/44'/1'/{account}'/{change}/{idx}

m/44'/1' => tpubDALcajyQQtb5HRLZ8jAJhVhxbGVY7vSJWfxuYUknNMQDZzjQdWtge5GDNnqw5jB8wCDuDXp1tJQkFbZyE1YmYawBrJZiHeRWfXr7KBQoxUM

... first 5 receive addresses (account=0, change=0):

m/44'/1'/0'/0/0 => n2sEggcZ9vztixvwaEtf9aJPXTze4qcyEK
m/44'/1'/0'/0/1 => mix1rdoLEzR1n7pmfkRLJRL2eCVhoL9xD6
m/44'/1'/0'/0/2 => mwAy5FLgdKzGnjTwUbkpd7Fp97cRKNjY56
m/44'/1'/0'/0/3 => mi5RvZpkR9yKtxLiVwWqYXiHaYzjskSKgF
m/44'/1'/0'/0/4 => mujhjLQ9cpyqNjbv6NAPTUA6HWjBP64HZv


## For BIP49 (P2WPKH-nested-in-P2SH): m/49'/1'/{account}'/{change}/{idx}

m/49'/1' => tpubDBJSfnStqiS6NpVyZjTGpR27FQQG5x6nAKwycydndiNUcuexGYbc5aW5KE9bAKmTWRWQF6ihZySoZHRLZk3hCFGfjS3nUNgkrS29K3Aa635
# SLIP-132 style
m/49'/1' => upub5CS2EYcTgPrCZ8jmcU7JzEQEQNsGGhdDsMo1vEtz9nUwiKYZSMFq4wrq1aC3e6rTVbd5P6R9etZ7DF631nxQv6ma4pDD37a4TJEoPMWrETv

... first 5 receive addresses (account=0, change=0):

m/49'/1'/0'/0/0 => 2NFLZEZVQizq4j1RbPmrM4PDCBVBJT8yz8g
m/49'/1'/0'/0/1 => 2MtnK8YM3trNgW1SGKnHVLxUGQinHJ9gzJN
m/49'/1'/0'/0/2 => 2Muj9cwcCCm6r7qpLxUHe1mRz4D1ikmuGSu
m/49'/1'/0'/0/3 => 2NAwepU6eSdb1c6nnV13SJAqSJEYjbUeNGB
m/49'/1'/0'/0/4 => 2N7bVgw1d1jmipnFL95droVt5JgKvfw9cRr


## For BIP84 (Native Segwit P2PKH): m/84'/1'/{account}'/{change}/{idx}

m/84'/1' => tpubDAZhhJ9SaAKCt2gngU8aA2babxVAM93oBgo2wGknMUDmtLrzvLnynFuAYo4eME3MqWpcTM3DpGL9J45nQw7CA7VroAY8e7v9Zo6r7mddUMS
# SLIP-132 style
m/84'/1' => vpub5WXYZiyvZXGnue7hZZaEXw5Cvu6cUWZjoqAJ1vusFYi82rZqLocmPgv4GM4gpunHEL46LpLEMqnzqJN3agRvgCgMztPynmcwSPP9aYGfxLs

... first 5 receive addresses (account=0, change=0):

m/84'/1'/0'/0/0 => tb1qtymulkjmx26pvq6n45sly2gmttwc4g5vtgzxez
m/84'/1'/0'/0/1 => tb1q4gcq8et9qvjy3cffzqmhr2qtchhvdy9x6v08cd
m/84'/1'/0'/0/2 => tb1qnmw70uefcns626xu4umftmqx8n7wjusxej7k32
m/84'/1'/0'/0/3 => tb1qzdtj4cn6kj3lt3uha9my2skh0a99e0u59tw45r
m/84'/1'/0'/0/4 => tb1q27ysu4ut4v3wv4xsq55wvrlyn7n4xqjfsslz4h

我想導入 BIP84 tpub,所以我使用上面提供的 BIP84 tpub。

在比特幣核心中,我稱之為:

bitcoin-cli getdescriptorinfo "wpkh([18734cbe/84h/1h/0h]tpubDAZhhJ9SaAKCt2gngU8aA2babxVAM93oBgo2wGknMUDmtLrzvLnynFuAYo4eME3MqWpcTM3DpGL9J45nQw7CA7VroAY8e7v9Zo6r7mddUMS
/0/*)"

responseString = {

 "descriptor": "wpkh([18734cbe/84'/1'/0']tpubDAZhhJ9SaAKCt2gngU8aA2babxVAM93oBgo2wGknMUDmtLrzvLnynFuAYo4eME3MqWpcTM3DpGL9J45nQw7CA7VroAY8e7v9Zo6r7mddUMS/0/*)#4c563hxu",
 "isrange": true,
 "issolvable": true,
 "hasprivatekeys": false

}

bitcoin-cli -rpcwallet=BIP84 importmulti '[{ "desc": "wpkh([18734cbe/84'"'"'/1'"'"'/0'"'"']tpubDAZhhJ9SaAKCt2gngU8aA2babxVAM93oBgo2wGknMUDmtLrzvLnynFuAYo4eME3MqWpcTM3DpGL9J45nQw7CA7VroAY8e7v9Zo6r7mddUMS/0/*)#4c563hxu", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false }]' '{"rescan": false}'

result = (
       {
       success = 1;
   }
)

我嘗試了很多組合,但這最能反映我在這裡找到的說明<https://github.com/bitcoin-core/HWI/blob/master/docs/bitcoin-core-usage.md>

當我打電話時:

bitcoin-cli -rpcwallet=BIP84 getnewaddress "*", "bech32"
responseString = tb1qf3fvy6s4a6y659cmrp829z9g8743ne7zynrzdu

這不是一個正確的地址。誰能指出我在這裡做錯了什麼?

編輯:

bitcoin-cli -rpcwallet=BIP84 getaddressinfo "tb1qf3fvy6s4a6y659cmrp829z9g8743ne7zynrzdu"
{
 "address": "tb1qf3fvy6s4a6y659cmrp829z9g8743ne7zynrzdu",
 "scriptPubKey": "00144c52c26a15ee89aa171b184ea288a83fab19e7c2",
 "ismine": false,
 "solvable": true,
 "desc": "wpkh([18734cbe/84'/1'/0'/0/0]02e36718f3ef012d322e335dc85e8ef9fcd5b859b719800a111ac46ea67cf34b1f)#rj2ve2jp",
 "iswatchonly": true,
 "isscript": false,
 "iswitness": true,
 "witness_version": 0,
 "witness_program": "4c52c26a15ee89aa171b184ea288a83fab19e7c2",
 "pubkey": "02e36718f3ef012d322e335dc85e8ef9fcd5b859b719800a111ac46ea67cf34b1f",
 "label": "*,",
 "ischange": false,
 "timestamp": 0,
 "hdkeypath": "m/84'/1'/0'/0/0",
 "hdseedid": "0000000000000000000000000000000000000000",
 "hdmasterfingerprint": "18734cbe",
 "labels": [
   {
     "name": "*,",
     "purpose": "receive"
   }
 ]
}

我為冷卡錢包使用過時的韌體,所以這可能是問題,將更新它再試一次並恢復。

將 ColdCard 更新到最新(未發布)韌體顯示 xpub 與我的上述程式碼兼容,並且與上述範例完美配合。

具有新轉儲摘要輸出的相同 ColdCard:

# Coldcard Wallet Summary File
## For wallet with master key fingerprint: 18734CBE

Wallet operates on blockchain: Bitcoin Testnet

For BIP44, this is coin_type '1', and internally we use
symbol XTN for this blockchain.

## IMPORTANT WARNING

Do **not** deposit to any address in this file unless you have a working
wallet system that is ready to handle the funds at that address!

## Top-level, 'master' extended public key ('m/'):

tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY

What follows are derived public keys and payment addresses, as may
be needed for different systems.


## For Bitcoin Core: m/{account}'/{change}'/{idx}'

First 5 receive addresses (account=0, change=0):

m/0'/0'/0' =&gt; tpubDCATeo6yFBpS7m1szppzMD7zkNcgECxMe8LBxePPEYoPzFmZGQp2pismcwtB4va9pXoGVMjRXGtqQHFKg1adNSy6GXGEnSYtdaeSww1Dkdg
m/0'/0'/0' =&gt; mwokgDX6HQREsFgevxZwKDxmVfDjEqwPuC

m/0'/0'/1' =&gt; tpubDCATeo6yFBpSAe4W2y8LkYvvzzQrJgyQS95Uys623N17e4Rnc33kkbv2LPkB45aWAUkdttapuEjQRK5pRLD6B1Z8dRRrBdwFBTAQGz5HMDe
m/0'/0'/1' =&gt; mwGmYgnd3MDjaTXfp5dgq5YxNtGjfRyTuT

m/0'/0'/2' =&gt; tpubDCATeo6yFBpSDMgwGGC9vQkadkkFFDgsSP67BrFpZ543PMgaLuof9EYmdvAxLeCyuG8B6XP6q1yywfaFGofdnmMTN9LooLzSeb93dH3tTQE
m/0'/0'/2' =&gt; mntHLuyhXr6QsVsWstRs3XFHaMXD8AKuLo

m/0'/0'/3' =&gt; tpubDCATeo6yFBpSGritemWBfB6SGxjzKXZdk9SKW2Kwpj4Qm6efgQjEV1nmj16ZAuxguYJWCvSeibnGpeSaNMb44MZnCJ9LajcHuSCis7Ect3n
m/0'/0'/3' =&gt; msU7yGFgbqTJF9n55jYB8e3Hxh4hi7vhhF

m/0'/0'/4' =&gt; tpubDCATeo6yFBpSJGFBLgD7UAmveDdpnCsjT6Dy1YZD5XsbUNyzc4aczhTF9956SZN6mREKDmeQFnkTtHfRTAvh6NQZoZ6oHMickZBu9GXkGRW
m/0'/0'/4' =&gt; mjdKAoMcyieEwcscdvrnKzqu4r6bnfQMj1


## For Bitcoin Core (Segregated Witness, P2PKH): m/{account}'/{change}'/{idx}'

First 5 receive addresses (account=0, change=0):

m/0'/0'/0' =&gt; tpubDCATeo6yFBpS7m1szppzMD7zkNcgECxMe8LBxePPEYoPzFmZGQp2pismcwtB4va9pXoGVMjRXGtqQHFKg1adNSy6GXGEnSYtdaeSww1Dkdg
m/0'/0'/0' =&gt; tb1qk2hk9sdh0akzyc99nx65a2erpuftcek3v4mret

m/0'/0'/1' =&gt; tpubDCATeo6yFBpSAe4W2y8LkYvvzzQrJgyQS95Uys623N17e4Rnc33kkbv2LPkB45aWAUkdttapuEjQRK5pRLD6B1Z8dRRrBdwFBTAQGz5HMDe
m/0'/0'/1' =&gt; tb1q4nfn0gme6yr9fezwlrdzdycfpztswal0j4l38m

m/0'/0'/2' =&gt; tpubDCATeo6yFBpSDMgwGGC9vQkadkkFFDgsSP67BrFpZ543PMgaLuof9EYmdvAxLeCyuG8B6XP6q1yywfaFGofdnmMTN9LooLzSeb93dH3tTQE
m/0'/0'/2' =&gt; tb1q2rgcg659h4fte2c6dzljzskyjz5qfftrfwcyv7

m/0'/0'/3' =&gt; tpubDCATeo6yFBpSGritemWBfB6SGxjzKXZdk9SKW2Kwpj4Qm6efgQjEV1nmj16ZAuxguYJWCvSeibnGpeSaNMb44MZnCJ9LajcHuSCis7Ect3n
m/0'/0'/3' =&gt; tb1qsvv9dv4g7uepe5pk0tf3cp7hdgnmtx5hp626ap

m/0'/0'/4' =&gt; tpubDCATeo6yFBpSJGFBLgD7UAmveDdpnCsjT6Dy1YZD5XsbUNyzc4aczhTF9956SZN6mREKDmeQFnkTtHfRTAvh6NQZoZ6oHMickZBu9GXkGRW
m/0'/0'/4' =&gt; tb1q952xefka88ep3s8htxgnw0n60a4spqwfppm5mu


## For Electrum (not BIP44): m/{change}/{idx}

First 5 receive addresses (account=0, change=0):

m =&gt; tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY
m/0/0 =&gt; mu7NuiLq1PsK7ncvE5cN3YPwU89wCjz4fC
m/0/1 =&gt; mvSCNC4w9wBRksZwQsLPL4pyNMbHB8rFKy
m/0/2 =&gt; mooEuT4TzKte4yvNxk4T7Du9K9vG1ZfjyK
m/0/3 =&gt; mpuSJdR1W3WLEH1FN3KN3Mxye9dBnnJYd6
m/0/4 =&gt; miwaFWAkjmAggdFGix4SGiSxaq4zzue78B


## For BIP44 / Electrum: m/44'/1'/{account}'/{change}/{idx}

First 5 receive addresses (account=0, change=0):

m/44'/1'/0' =&gt; tpubDDZWqt7mxh5QsvFMmPtJcx1FGsXc5LXTaBFNfq9h8jF7UHhi4UWuVJLBT6qqGygoDzj3j1628QyzUwkK19FDGhKam2UXBLxNebBWNJVxn9z
m/44'/1'/0'/0/0 =&gt; n2sEggcZ9vztixvwaEtf9aJPXTze4qcyEK
m/44'/1'/0'/0/1 =&gt; mix1rdoLEzR1n7pmfkRLJRL2eCVhoL9xD6
m/44'/1'/0'/0/2 =&gt; mwAy5FLgdKzGnjTwUbkpd7Fp97cRKNjY56
m/44'/1'/0'/0/3 =&gt; mi5RvZpkR9yKtxLiVwWqYXiHaYzjskSKgF
m/44'/1'/0'/0/4 =&gt; mujhjLQ9cpyqNjbv6NAPTUA6HWjBP64HZv


## For BIP49 (P2WPKH-nested-in-P2SH): m/49'/1'/{account}'/{change}/{idx}

First 5 receive addresses (account=0, change=0):

m/49'/1'/0' =&gt; tpubDCKpfULue5a7s9eEYJR48AGYxTiQt3gFqJS7VLmYxFjEiw7zDGxYkxtFJsyJd6i5QPfDGvDF9YTZWXqXq47PmGmEf8FQedYZRtp6oJdR5Cu
m/49'/1'/0' =&gt; upub5DTQEEWUUkzE3Tt2b356Hyeg7SBR4oChYLH9nc2kUKqhpM1bP5cmkLF11E1m6so5PZmtQuuhETZsAVWEH727V8G8zWQqDNRs2m2ksa22a9V   ##SLIP-132##
m/49'/1'/0'/0/0 =&gt; 2NFLZEZVQizq4j1RbPmrM4PDCBVBJT8yz8g
m/49'/1'/0'/0/1 =&gt; 2MtnK8YM3trNgW1SGKnHVLxUGQinHJ9gzJN
m/49'/1'/0'/0/2 =&gt; 2Muj9cwcCCm6r7qpLxUHe1mRz4D1ikmuGSu
m/49'/1'/0'/0/3 =&gt; 2NAwepU6eSdb1c6nnV13SJAqSJEYjbUeNGB
m/49'/1'/0'/0/4 =&gt; 2N7bVgw1d1jmipnFL95droVt5JgKvfw9cRr


## For BIP84 (Native Segwit P2PKH): m/84'/1'/{account}'/{change}/{idx}

First 5 receive addresses (account=0, change=0):

m/84'/1'/0' =&gt; tpubDCQUid7gmQWq7GLdF6D7fN8RFvEocAUUSxE1Sy74aqtCBgZ8pbPCGSNKpA8nGR8HwN9agAHS4kgngs2Ey9VVFgPKz8cDvBHHZ9sCqAtUVQK
m/84'/1'/0' =&gt; vpub5YNKb3xAkmUR8smY8Ben3Gc3arrFjXzR56bGXdG9UvNYLCFyF4CyssPDXi8pk6sDLBP4ZdaScL9eE7JW8tpDmmZqBrU54pz5Rk9WJ11aUMc   ##SLIP-132##
m/84'/1'/0'/0/0 =&gt; tb1qtymulkjmx26pvq6n45sly2gmttwc4g5vtgzxez
m/84'/1'/0'/0/1 =&gt; tb1q4gcq8et9qvjy3cffzqmhr2qtchhvdy9x6v08cd
m/84'/1'/0'/0/2 =&gt; tb1qnmw70uefcns626xu4umftmqx8n7wjusxej7k32
m/84'/1'/0'/0/3 =&gt; tb1qzdtj4cn6kj3lt3uha9my2skh0a99e0u59tw45r
m/84'/1'/0'/0/4 =&gt; tb1q27ysu4ut4v3wv4xsq55wvrlyn7n4xqjfsslz4h

然後在 Bitcoin Core 中使用 BIP84 的更新指紋和 tpub:

bitcoin-cli getdescriptorinfo "wpkh([18734CBE/84h/1h/0h]tpubDCQUid7gmQWq7GLdF6D7fN8RFvEocAUUSxE1Sy74aqtCBgZ8pbPCGSNKpA8nGR8HwN9agAHS4kgngs2Ey9VVFgPKz8cDvBHHZ9sCqAtUVQK/0/*)"
responseString = {
 "descriptor": "wpkh([18734cbe/84'/1'/0']tpubDCQUid7gmQWq7GLdF6D7fN8RFvEocAUUSxE1Sy74aqtCBgZ8pbPCGSNKpA8nGR8HwN9agAHS4kgngs2Ey9VVFgPKz8cDvBHHZ9sCqAtUVQK/0/*)#8enle6r3",
 "isrange": true,
 "issolvable": true,
 "hasprivatekeys": false
}
bitcoin-cli -rpcwallet=ColdCardUpdate importmulti '[{ "desc": "wpkh([18734cbe/84'"'"'/1'"'"'/0'"'"']tpubDCQUid7gmQWq7GLdF6D7fN8RFvEocAUUSxE1Sy74aqtCBgZ8pbPCGSNKpA8nGR8HwN9agAHS4kgngs2Ey9VVFgPKz8cDvBHHZ9sCqAtUVQK/0/*)#8enle6r3", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false }]' '{"rescan": false}'
responseString = [
 {
   "success": true
 }

bitcoin-cli -rpcwallet=ColdCardUpdate getnewaddress "", "bech32"

responseString = tb1qtymulkjmx26pvq6n45sly2gmttwc4g5vtgzxez

引用自:https://bitcoin.stackexchange.com/questions/88545