如何用 Bitcoin Core 命令行创建 Safe 金库
准备 Bitcoin Core 钱包
下载 Bitcoin Core 钱包 https://github.com/bitcoin/bitcoin/releases ,注意下载 25.0 以上的版本才行。
您还可以选择 用 Bitcoin Core GUI 创建 Safe 金库
按照文档指南编译配置好钱包 https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md
进入 src 目录,终端输入命令后台运行比特币客户端:
./bitcoind -daemon
Bitcoin Core starting
用 Bitcoin Core 管理 Safe 金库不需要同步比特币节点数据!
创建 Safe 金库
1、进入 Safe 后台,新建 Safe 金库
2、输入金库名称选择 Bitcoin 网络
3、钱包选择 Bitcoin Core
选择 Bitcoin Core 来管理 Safe 金库,需要在 Bitcoin Core 钱包里创建两个钱包:
私钥钱包,管理密钥(私钥和公钥)
脚本钱包,负责多签交易、管理 UTXO
3.1 在终端中输入以下命令创建私钥钱包:
$ ./bitcoin-cli createwallet mixin-safe-holder
{
"name": "mixin-safe-holder"
}
3.2 输入以下命令获得私钥钱包地址:
$ ./bitcoin-cli --rpcwallet=mixin-safe-holder getnewaddress safe legacy
1Gz4GoSjNV8MxLFt8bE8JTfqJp6b2bXhvZ
参数 safe:地址标签(label)
参数 legacy:必须是 legacy 格式,否则 signmessage 不支持
3.3 根据地址标签查询钱包地址:
$ ./bitcoin-cli --rpcwallet=mixin-safe-holder getaddressesbylabel safe
{
"1Gz4GoSjNV8MxLFt8bE8JTfqJp6b2bXhvZ": {
"purpose": "receive"
}
}
3.4 获取私钥钱包的 public key
$ ./bitcoin-cli --rpcwallet=mixin-safe-holder getaddressinfo 1Gz4GoSjNV8MxLFt8bE8JTfqJp6b2bXhvZ
{
"address": "1Gz4GoSjNV8MxLFt8bE8JTfqJp6b2bXhvZ",
"scriptPubKey": "76a914af5454090a5fed618162431ddc57f67c671e82fa88ac",
"ismine": true,
"solvable": true,
"desc": "pkh([e8a47a9c/44'/0'/0'/0/0]03b08eeab9826f10b68569ff9af26ea350675e9d5cf9274c1990cfe5d7cf2b186c)#n9cxzr97",
"parent_desc": "pkh([e8a47a9c/44'/0'/0']xpub6CKHxzDBDi8rRzUcRwaYhHgN6nRNuFSqh7dH3CTgzb2Qa7CN6DGzvTJpnoCgCYj9S5JsnXkbiCGgGWjh7egGBouV533cmY7xy7wUBuQGfvX/0/*)#c7p9wm6z",
"iswatchonly": false,
"isscript": false,
"iswitness": false,
"pubkey": "03b08eeab9826f10b68569ff9af26ea350675e9d5cf9274c1990cfe5d7cf2b186c",
"iscompressed": true,
"ischange": false,
"timestamp": 1686997004,
"hdkeypath": "m/44'/0'/0'/0/0",
"hdseedid": "0000000000000000000000000000000000000000",
"hdmasterfingerprint": "e8a47a9c",
"labels": [
"safe"
]
}
3.5 复制 pubkey 粘贴到 safe 后台并下一步保存:
4、设置资产共管人
添加你信任的家人、朋友或者同事为资产共管人,并设置合理的共管模式。
5、预览并创建金库
6、激活金库
6.1 解码 Safe 金库数据
从 Safe 后台复制激活页面步骤 1 脚本数据,用以下命令解码数据
$ ./bitcoin-cli decodescript 2103b08eeab9826f10b68569ff9af26ea350675e9d5cf9274c1990cfe5d7cf2b186cac7c210261300cb233f092c6c2f787139624b88ea4c774e779b3a257b36a2fcf186a09a7ac937c82926321026e37ea6e1e9a018753e3289387306d8d605351803497021c1a7cf7e6c0a8dab6ad02b001b29268935287
{
"asm": "03b08eeab9826f10b68569ff9af26ea350675e9d5cf9274c1990cfe5d7cf2b186c OP_CHECKSIG OP_SWAP 0261300cb233f092c6c2f787139624b88ea4c774e779b3a257b36a2fcf186a09a7 OP_CHECKSIG OP_ADD OP_SWAP OP_SIZE OP_0NOTEQUAL OP_IF 026e37ea6e1e9a018753e3289387306d8d605351803497021c1a7cf7e6c0a8dab6 OP_CHECKSIGVERIFY 432 OP_CHECKSEQUENCEVERIFY OP_0NOTEQUAL OP_ENDIF OP_ADD 2 OP_EQUAL",
"desc": "raw(2103b08eeab9826f10b68569ff9af26ea350675e9d5cf9274c1990cfe5d7cf2b186cac7c210261300cb233f092c6c2f787139624b88ea4c774e779b3a257b36a2fcf186a09a7ac937c82926321026e37ea6e1e9a018753e3289387306d8d605351803497021c1a7cf7e6c0a8dab6ad02b001b29268935287)#q9ngh6sm",
"type": "nonstandard",
"p2sh": "3J7w4UTU99Q55q3nxse4qGece52Nc21LKD",
"segwit": {
"asm": "0 0f338779ff70a9233ba47940b9136ef7f6f5c7524b49bb01ad66baad9d8864dc",
"desc": "wsh(thresh(2,pk(03b08eeab9826f10b68569ff9af26ea350675e9d5cf9274c1990cfe5d7cf2b186c),s:pk(0261300cb233f092c6c2f787139624b88ea4c774e779b3a257b36a2fcf186a09a7),sj:and_v(v:pk(026e37ea6e1e9a018753e3289387306d8d605351803497021c1a7cf7e6c0a8dab6),n:older(432))))#p6vc2x03",
"hex": "00200f338779ff70a9233ba47940b9136ef7f6f5c7524b49bb01ad66baad9d8864dc",
"address": "bc1qpuecw70lwz5jxway09qtjymw7lm0t36jfdymkqddv6a2m8vgvnwqfnt0pq",
"type": "witness_v0_scripthash",
"p2sh-segwit": "342sprEcLKM3sYrCfPtdLemasXwYnAukT3"
}
}
6.2 创建脚本钱包
$ ./bitcoin-cli -named createwallet wallet_name="mixin-safe" disable_private_keys=true blank=true load_on_startup=true
{
"name": "mixin-safe"
}
6.3 导入描述符到脚本钱包
将步骤 6.1 解码出来的数据里 segwit 下的 desc 按格式 '[{"desc":"xxx","timestamp":"now","internal":false}]’ 拼接为描述符导入脚本钱包:
$ ./bitcoin-cli --rpcwallet=mixin-safe importdescriptors '[{"desc":"wsh(thresh(2,pk(03b08eeab9826f10b68569ff9af26ea350675e9d5cf9274c1990cfe5d7cf2b186c),s:pk(0261300cb233f092c6c2f787139624b88ea4c774e779b3a257b36a2fcf186a09a7),sj:and_v(v:pk(026e37ea6e1e9a018753e3289387306d8d605351803497021c1a7cf7e6c0a8dab6),n:older(432))))#p6vc2x03","timestamp":"now","internal":false}]'
[
{
"success": true
}
]
6.4 签名 Safe 金库数据
按下面格式签名从 Safe 后台复制激活页面步骤 3 数据:
$ ./bitcoin-cli --rpcwallet=mixin-safe-holder signmessage 1Gz4GoSjNV8MxLFt8bE8JTfqJp6b2bXhvZ APPROVE:c09c6f5f-4461-46a2-a172-4cd970aab955:bc1qpuecw70lwz5jxway09qtjymw7lm0t36jfdymkqddv6a2m8vgvnwqfnt0pq
IOs73u6gnEy9hIIH6zpEXLtaQncAUYkCk6hV8LQxwdxvQz3jOLbEDXJpo669P6sXQVHHpmnlbDbt22HHdgigeYs=
注意 signmessage 第一个参数是私钥钱包的地址。
6.5 激活钱包
复制 6.4 签名后的数据到激活页面步骤 5 输入框,点激活按钮:
等待约 30 秒钟 Safe 金库激活成功,你可以通过以下命令检测 Safe 金库的充值地址是否和脚本钱包的地址一致:
$ ./bitcoin-cli --rpcwallet=mixin-safe getaddressesbylabel ""
{
"bc1qpuecw70lwz5jxway09qtjymw7lm0t36jfdymkqddv6a2m8vgvnwqfnt0pq": {
"purpose": "receive"
}
}
Safe 金库创建好后就可以往这个地址里充值 BTC 了。
更新于: 29/02/2024