V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  dzdh  ›  全部回复第 77 页 / 共 77 页
回复总数  1521
1 ... 68  69  70  71  72  73  74  75  76  77  
2020-03-18 21:00:26 +08:00
回复了 iqingqian 创建的主题 程序员 求个思路,实现 BTC 离线签名,进行广播交易
1.有一个比特币钱包地址和其私钥
2.通过 HTTP 接口或者自行同步全网数据获取到一个指定钱包地址的所有 unspent 交易获取其 txid
3.分别将每一笔交易当作 input 指定其付款到的目标地址并进行签名
4.通过本地钱包或者公网接口将签名过的交易广播到公网

php exp:
```php
$from_address = 'base32 string';
$from_address_wifkey = 'key';
$input_txid = 'sha';
$input_amount = 0.003;

$to_address = 'base32 string';
$amount = 0.001;
Transaction::builder()->input($input_txid,$input_amount)
->to($address2, $amount)
->hex();

// 把地址 1 的一笔收入记录 txid(入账 0.003) 拿出来 付给 address2(0.001)
// 然后 txid 被标记为 spent(从 unspent) 然后给 address2 0.001
// 剩下 0.002 怎么办?没有特殊处理的“富裕”金额将被作为全网确认奖励消耗
// 再如 from(txid,10)->to(address2,1) 剩 9 个 想付 2 个作为确认奖励那就再加一个收款方为付款方(我付给我自己) 7 个
// 即: from(txid,10)->to(address2,1)->to(from_address,7) : 10=7-1=2(“无人认领”的金额将作为奖励) to(from_address)视为“找零”
```
1 ... 68  69  70  71  72  73  74  75  76  77  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1053 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 23ms · UTC 19:36 · PVG 03:36 · LAX 12:36 · JFK 15:36
Developed with CodeLauncher
♥ Do have faith in what you're doing.