使用 Python 与您的 Coldcard 通信
项目描述
Coldcard CLI 和 Python 接口库
Coldcard 是用于#Bitcoin 的廉价、超安全和开源硬件钱包。
在ColdcardWallet.com上获取您的
这是通过 USB 与其通信所需的 python 代码和命令行实用程序。
日常使用设置
pip install 'ckcc-protocol[cli]'
这将安装一个有用的命令行程序:ckcc
如果您只想要 python 库,请使用:
pip install ckcc-protocol
设置如果您可能更改代码
- 做一个 git checkout
- 可能制作一个新的虚拟环境
- 跑:
pip install -r requirements.txt
pip install --editable '.[cli]'
要求
- python 3.6 或更高版本
hidapi以便携式方式进行 USB HID 访问。requirements.txt有关详细信息,请参阅文件。
CLI 示例
命令参数
% ckcc
Usage: ckcc [OPTIONS] COMMAND [ARGS]...
Options:
-s, --serial HEX Operate on specific unit (default: first found)
-x, --simulator Connect to the simulator via Unix socket
-P, --plaintext Disable USB link-layer encryption
--help Show this message and exit.
Commands:
addr Show the human version of an address
auth Indicate specific user is present (for HSM).
backup Creates 7z encrypted backup file after...
bag Factory: set or read bag number -- single use...
chain Get which blockchain (Bitcoin/Testnet) is...
convert2cc Convert existing Electrum wallet file into...
debug Start interactive (local) debug session
eval Simulator only: eval a python statement
exec Simulator only: exec a python script
get-locker Get the value held in the Storage Locker (not...
hsm Get current status of HSM feature.
hsm-start Enable Hardware Security Module (HSM) mode.
list List all attached Coldcard devices
local-conf Generate the 6-digit code needed for a...
logout Securely logout of device (will require...
msg Sign a short text message
multisig Create a skeleton file which defines a...
p2sh Show a multisig payment address on-screen.
pass Provide a BIP39 passphrase
pubkey Get the public key for a derivation path Dump...
reboot Reboot coldcard, force relogin and start over
sign Approve a spending transaction by signing it...
test Test USB connection (debug/dev)
upgrade Send firmware file (.dfu) and trigger upgrade...
upload Send file to Coldcard (PSBT transaction or...
user Create a new user on the Coldcard for HSM...
version Get the version of the firmware installed
xfp Get the fingerprint for this wallet (master...
xpub Get the XPUB for this wallet (master level,...
消息签名
% ckcc msg --help
Usage: ckcc msg [OPTIONS] MESSAGE
Sign a short text message
Options:
-p, --path DERIVATION Derivation for key to use [default: m/44'/0'/0'/0/0]
-v, --verbose Include fancy ascii armour
-j, --just-sig Just the signature itself, nothing more
-s, --segwit Address in segwit native (p2wpkh, bech32)
-w, --wrap Address in segwit wrapped in P2SH (p2wpkh)
--help Show this message and exit.
% ckcc msg "Hello Coldcard" -p m/34/23/33
Waiting for OK on the Coldcard...
Hello Coldcard
1KSXaNHh3G4sfTMsp9q8CmACeqsJn46drd
H4mTuwMUdnu3MyMA+6aJ3hiAF4L0WBDZFseTEno511hNN8/THIeM4GW4SnrcJJhS3WxMZEWFdEIZDSP+H5aIcao=
交易签名
% ckcc sign --help
Usage: ckcc sign [OPTIONS] PSBT_IN [PSBT_OUT]
Approve a spending transaction by signing it on Coldcard
Options:
-v, --verbose Show more details
-f, --finalize Show final signed transaction, ready for transmission
-z, --visualize Show text of Coldcard's interpretation of the transaction
(does not create transaction, no interaction needed)
-s, --signed Include a signature over visualization text
-x, --hex Write out (signed) PSBT in hexidecimal
-6, --base64 Write out (signed) PSBT encoded in base64
--help Show this message and exit.
% (... acquire PSBT file for what you want to do ...)
% ckcc sign example.psbt out.psbt
5071 bytes (start @ 0) to send from 'example.psbt'
Uploading [####################################] 100%
Waiting for OK on the Coldcard...
Ok! Downloading result (5119 bytes)
% hexdump -C out.psbt | head -3
00000000 70 73 62 74 ff 01 00 fd 22 04 02 00 00 00 04 3f |psbt...."......?|
00000010 ee 16 30 9d 14 82 36 dd c8 3e 9e 4f 94 47 83 00 |..0...6..>.O.G..|
00000020 c2 23 e1 06 22 1b 02 0e bd c8 1c 71 79 7d 3c 02 |.#.."......qy}<.|
00000030 00 00 00 00 fe ff ff ff 4c 85 a0 2c 80 cb 2c 01 |........L..,..,.|
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
ckcc-protocol-1.3.2.tar.gz
(31.8 kB
查看哈希)
内置分布
ckcc_protocol-1.3.2-py3-none-any.whl
(33.4 kB
查看哈希)
关
ckcc_protocol -1.3.2-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | b25d73abe53ed9d3231393a904a0f63ff094f6975b6a714a0a0f08eecb367f91 |
|
| MD5 | 0995b8d8f0d899d98d5f7a77af28dd04 |
|
| 布莱克2-256 | e7b05c5f16c544165dbd23b71ddf6f132237f9e882619734eadd52acd9b8a86e |