pxsocs / warden_terminal

WARden with an enhanced Text User Interface for Unix based systems
72 stars 14 forks source link

means of acquiring the whitepaper #2

Closed nyxnor closed 3 years ago

nyxnor commented 3 years ago

Prazer, sou nyx.

https://github.com/pxsocs/warden_terminal/blob/67a22e1479b7a1456c1a1ac1b36b5ffbc42b3376/data.py#L331

Using bitcoin.org, but it is a central server and even if their copy is taken down?

Consider sourcing from the blockchain,

of course user can scp to another computer if running headless, but a solution to show the text from the terminal is:

pdftotext bitcoin.pdf
less bitcoin.txt
pxsocs commented 3 years ago

Opa @nyxnor! Thanks for the input. Will probably head the same way Specter implemented this. Added to next improvement list.

pxsocs commented 3 years ago

This has been fixed with a new download method using RPC as a primary source and will be deployed in the next version after testing.

The app will try in order:

  1. The method below get_whitepaper()

  2. A Linux script as suggested by @nyxnor: sudo -u bitcoin bitcoin-cli getblock 00000000000000ecbbff6bafb7efa2f7df05b227d5c73dca8f2635af32a2e949 0 | tail -c+92167 | for ((o=0;o<946;++o)) ; do read -rN420 x ; echo -n ${x::130}${x:132:130}${x:264:130} ; done | xxd -r -p | tail -c+9 | head -c184292 > bitcoin.pdf

  3. If all fails, will try to download from bitcoin.org.

RPC Method:


def get_whitepaper():
    rpc_connection = rpc_connect()
    hash = "54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713"
    outputs_prun = []
    for i in range(0, 946):
        outputs_prun.append(rpc_connection.gettxout(hash, i))

    pdf = ""
    for output in outputs_prun[:-1]:
        cur = 4
        pdf += output["result"]["scriptPubKey"]["hex"][cur:cur + 130]
        cur += 132
        pdf += output["result"]["scriptPubKey"]["hex"][cur:cur + 130]
        cur += 132
        pdf += output["result"]["scriptPubKey"]["hex"][cur:cur + 130]
    pdf += outputs_prun[-1]["result"]["scriptPubKey"]["hex"][4:-4]

    from pathlib import Path
    filename = Path('bitcoin_whitepaper_from_node.pdf')

    with open(filename, "w") as text_file:
        text_file.write(pdf)

    return (f"Success. File {str(filename)} saved.")