2023-07-01 15:51:37 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
#
|
2024-10-18 10:32:06 +00:00
|
|
|
# MMGen Wallet, a terminal-based cryptocurrency wallet
|
2024-01-19 11:05:10 +00:00
|
|
|
# Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
|
2023-07-01 15:51:37 +00:00
|
|
|
# Licensed under the GNU General Public License, Version 3:
|
|
|
|
|
# https://www.gnu.org/licenses
|
|
|
|
|
# Public project repositories:
|
2023-11-17 13:35:42 +00:00
|
|
|
# https://github.com/mmgen/mmgen-wallet
|
|
|
|
|
# https://gitlab.com/mmgen/mmgen-wallet
|
2023-07-01 15:51:37 +00:00
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
examples/whitepaper.py: extract the Bitcoin whitepaper from the blockchain
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
|
from mmgen.cfg import Config
|
|
|
|
|
from mmgen.rpc import rpc_init
|
|
|
|
|
|
|
|
|
|
txid = '54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713'
|
|
|
|
|
fn = 'bitcoin.pdf'
|
|
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
|
|
|
|
|
|
cfg = Config(process_opts=True)
|
|
|
|
|
|
|
|
|
|
assert cfg.coin == 'BTC' and cfg.network == 'mainnet', 'This script works only on BTC mainnet!'
|
|
|
|
|
|
2023-07-03 12:42:49 +00:00
|
|
|
c = await rpc_init( cfg, ignore_wallet=True )
|
2023-07-01 15:51:37 +00:00
|
|
|
|
|
|
|
|
tx = await c.call('getrawtransaction',txid,True)
|
|
|
|
|
|
|
|
|
|
chunks = [''.join( d['scriptPubKey']['asm'].split()[1:4] ) for d in tx['vout']]
|
|
|
|
|
|
|
|
|
|
with open(fn,'wb') as f:
|
|
|
|
|
f.write(bytes.fromhex( ''.join(chunks)[16:368600] ))
|
|
|
|
|
|
|
|
|
|
print(f'Wrote {fn}')
|
|
|
|
|
|
|
|
|
|
asyncio.run(main())
|