forked from scottlingran/bitcoin-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.rb
More file actions
29 lines (21 loc) · 648 Bytes
/
test.rb
File metadata and controls
29 lines (21 loc) · 648 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'pry'
require 'helloblock-lite'
Bitcoin.network = :testnet3
include Bitcoin::Builder
priv = "f457f5c3ce39c5041935f047525e3d12d74a7a4ba7321393bf8167a465051b99"
key = Bitcoin::Key.new(priv, nil, false)
unspent = HelloBlock::Address.get_unspents(key.addr)[0]
binding.pry
new_tx = build_tx do |t|
t.input do |i|
i.prev_out unspent["txHash"]
i.prev_out_index unspent["index"]
i.prev_out_script [unspent["scriptPubKey"]].pack("H*")
i.signature_key key
end
t.output do |o|
o.value unspent["value"]
o.script { |s| s.recipient("2N5snPEHUgsw5FjypjZ5zR8DQKqotmU5YAR") }
end
end
p new_tx.payload.unpack("H*")[0]