2 个不稳定版本
0.2.0 | 2022年12月8日 |
---|---|
0.1.0 | 2022年12月6日 |
#95 in #privacy
21KB
382 行
隐私支付 CLI 工具
用于处理比特币隐私支付隐形地址系统的命令行工具。
- 生成接收者支付代码
- 创建发送者通知有效载荷
- 解码通知以揭示隐形地址
安装
从 Crates.io
cargo install privpay
privpay -h
本地开发
git clone https://github.com/private-payments/privpay-cli.git
cd privpay-cli
cargo build
示例
从BIP351重建示例
# Generate Bob's Payment Code
$ privpay receiver code -t p2pkh -t p2wpkh
# <enter ff for seed hex>
pay1qqpsxq4730l4yre4lt3588eyt3f2lwggtfalvtgfns04a8smzkn7yys6xv2gs8
# Alice notifying Bob and deriving the first stealth address
$ privpay sender notify -r 0 -t p2wpkh pay1qqpsxq4730l4yre4lt3588eyt3f2lwggtfalvtgfns04a8smzkn7yys6xv2gs8
# <enter fe for seed hex>
OP_RETURN OP_PUSHBYTES_40 505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401
0: bc1qw7ld5h9tj2ruwxqvetznjfq9g5jyp0gjhrs30w
# Bob deriving same stealth address
privpay receiver decode -P 6a28505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401
# <enter ff for seed hex>
0: bc1qw7ld5h9tj2ruwxqvetznjfq9g5jyp0gjhrs30w 03e669bd1705691a080840b07d76713d040934a37f2e8dde2fe02f5d3286a49219 L1fJmsaHyM96XrpHs765ueXfmv1V7TiNgWJHS8ZsTgfVFvLd1TcU
JSON 输出
使用 --json
输出标志运行前面的示例会产生更详细的信息。
生成 Bob 的支付代码
$ privpay receiver code --json -t p2pkh -t p2wpkh
# <enter ff for seed hex>
{
"payment_code": "pay1qqpsxq4730l4yre4lt3588eyt3f2lwggtfalvtgfns04a8smzkn7yys6xv2gs8",
"account": 0,
"bip32_path": "m/351'/0'/0'",
"address_types": [
"p2wpkh",
"p2pkh"
]
}
Alice 通知 Bob 并推导出第一个隐形地址
$ privpay sender notify --json -r 0 -t p2wpkh pay1qqpsxq4730l4yre4lt3588eyt3f2lwggtfalvtgfns04a8smzkn7yys6xv2gs8
# <enter fe for seed hex>
{
"receiver": {
"payment_code": "pay1qqpsxq4730l4yre4lt3588eyt3f2lwggtfalvtgfns04a8smzkn7yys6xv2gs8",
"index": 0
},
"sender": {
"account": 0,
"bip32_path": "m/351'/0'/0'"
},
"notification": {
"scriptpubkey": "6a28505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401",
"payload": "505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401",
"asm": "OP_RETURN OP_PUSHBYTES_40 505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401"
},
"addresses": [
{
"address": "bc1qw7ld5h9tj2ruwxqvetznjfq9g5jyp0gjhrs30w",
"index": 0
}
]
}
Bob 推导出相同的隐形地址
privpay receiver decode --json -P 6a28505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401
# <enter ff for seed hex>
{
"receiver": {
"payment_code": "pay1qqpqxq4730l4yre4lt3588eyt3f2lwggtfalvtgfns04a8smzkn7yys66cs29t",
"account": 0,
"bip32_path": "m/351'/0'/0'"
},
"notification": {
"scriptpubkey": "6a28505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401",
"payload": "505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401",
"asm": "OP_RETURN OP_PUSHBYTES_40 505049cb55bb02e3217349724307eed5514b53b1f53f0802672a9913d9bbb76afecc86be23f46401"
},
"addresses": [
{
"address": "bc1qw7ld5h9tj2ruwxqvetznjfq9g5jyp0gjhrs30w",
"index": 0,
"public_key": "03e669bd1705691a080840b07d76713d040934a37f2e8dde2fe02f5d3286a49219",
"private_key": "L1fJmsaHyM96XrpHs765ueXfmv1V7TiNgWJHS8ZsTgfVFvLd1TcU"
}
]
}
依赖项
~9–17MB
~166K SLoC