Skip to content

markrussinovich/btcgraffiti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BTC-Graffiti

BTC-Graffiti is a pair of scripts where btcg-encode encodes a specified file into a Bitcoin transaction using the Pay-2-Fake-Key-Hash (P2FKH) technique that encodes data into transaction output script addresses, and btcg-decode extracts the addresses and reconsistitutes the encoded file. The encoder stores the name of the source file in the OP_RETURN and the decode script stores the extracted data to that file name. Data can be of any format, including text, images, and audio. Content you store this way is permanent.

Because data BTC-Graffiti posts lives forever on the Bitcoin blockchain, BTC-Graffiti posts make the perfect birthday or Valentine's day gift!

Encoding Data

To encode a file, execute the encoding script like this:

> python btcg-encode.py <file> --key KEY [--utxo UTXO] [--net <main|test>]

The private key corresponds to the account that holds the Bitcoin the script uses for the transaction and must be in WIF compressed format. An easy way to generate an an address/key pair compatible with the script is to use bitaddress.org and send data from an existing address to the one you generate.

Here's an example command that successfully encoded data:

> python btcg-encode.py satoshi.png --key #########

BTC Graffiti Encoder - by Mark Russinovich (@markrussinovich)
Write data into Bitcoin transactions.

Encoding 'satoshi.png'...
Looking up account balance for 1Lc35WwyqSbW4quqY8CNHrVmjUXsK2Xcwq...
File encoded to transaction c8a7afbff7d11b3627bb43251843394dfbf26d696e0f475950ac2fd39d5b4c2b

Decoding Data

To decode a transaction that has BTC-Graffiti data encoded into it, use the decoding script like this:

python btcg-decode <transaction> [--net <main|test>]

This example downloads a test message BTC-Graffiti stored in a transaction:

> python btcg-decode.py bd71fc8ceadc75a35f0c96556aabcc24a24bc458e4167969ed62ec7fe1efd024

BTC Graffiti Decoder - by Mark Russinovich (@markrussinovich)
Read data from Bitcoin transaction.

Reading transaction...
Writing encoded data to test.txt...
Transaction decoded to test.txt.

> type test.txt
BTCG lives forever!

And this transaction is a tribute to Satoshi, storing the abstract for his paper announcing Bitcoin:

> python btcg-decode.py c8a7afbff7d11b3627bb43251843394dfbf26d696e0f475950ac2fd39d5b4c2b

BTC Graffiti Decoder - by Mark Russinovich (@markrussinovich)
Read data from  Bitcoin transaction.

Reading transaction...
Writing encoded data to satoshi.png...
Transaction decoded to satoshi.png.

This is the image saved to satoshi.png and here's a link to details of the transaction:

Satoshi.png transaction on blockchain.com

Satoshi.png

Implementation

BTC-Graffiti uses the Bit Python library for creating and transmitting transactions, and functions from the Cryptos python library for decoding them:

Data on the Bitcoin Blockchain

People have been storing data on the Bitcoin blockchain starting with Satoshi's genesis block message. Here are some sites and papers that discuss encoding techniques, the implications of data immutability, and give examples of other data encoded on Bitcoin:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages