Skip to content

Instantly share code, notes, and snippets.

@azuchi
Created January 28, 2021 13:58
Bitcoinのホワイトペーパーをチェーン上からデコードするプログラム
tx = Bitcoin::Tx.parse_from_payload('Tx 54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713のHexデータ').htb)
File.open('bitcoin.pdf', mode = 'w') do |f|
tx.outputs[0...-2].map.with_index do |o, i|
data = o.script_pubkey.get_multisig_pubkeys.map.with_index do |p, j|
if i == 0 && j ==0
p[(p.index("%PDF-"))..-1]
elsif i == 945
p[0...-8]
else
p
end
end.join
f.write data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment