It is a GUI application that implements the basic functions of the Bitcoin wallet. It is also possible to actually exchange bitcoins with this app. (We can't guarantee the operation, so we don't recommend it. If you do, it's a small amount ...)
https://github.com/momosuke4989/pycoin-demo
A library called pycoin was introduced in Mastering Bitcoin, which is a bitcoin bible, so I created it after studying python and bitcoin. At the Open Source Conference 2016 Tokyo / Fall, I was demonstrating with a Raspberry Pi with a 3.2 inch LCD. This is why the window size specification is strangely small.
See README key-generate.py is for Bitcoin address generation and create-tx.py is for transaction generation.
An app for general users to manage Bitcoin is called a wallet. The main functions are the storage and sending / receiving of Bitcoin, which consists of the following elements.
In the world of Bitcoin, users are identified by the unit of private key and Bitcoin address (hereinafter referred to as the address). If you replace it with the world of banks, the private key is a PIN and the address is an account number. Public key cryptography (or elliptic curve cryptography to be exact) and hash functions are used to generate addresses, but interestingly, no organization or entity controls this task. Since the range of values that the private key can take is large enough (10 ^ 77), it is practically safe to ignore the possibility of address collision. For this reason, it is commonplace in the Bitcoin world to have multiple addresses by one person, and it is said that it is desirable to generate an address for each transaction from the viewpoint of security, but the private key and address each time. It's a lot of work to generate, and it's also complicated to manage.
Hierarchical Deterministic Wallet A mechanism called Hierarchical Deterministic Wallet, commonly known as HD wallet, was proposed to solve this problem. The HD wallet is very convenient because you can generate multiple private keys / addresses hierarchically from one master key, and if you have the master key, you can also get the balance of all the addresses under the hierarchy.
Although the introduction has become quite long, key-generate.py is an application that generates a private key and address based on this mechanism.
To send Bitcoin to someone, the transfer information must be sent to the Bitcoin network in the form of a transaction and approved. However, in the world of Bitcoin, all the information about which address has and how much is open to the public, so it is easy to create a transaction such as sending money from another person's address in red to yourself. It would be irresistible if something like this was approved. In order to prevent such a situation, it is necessary to prevent Bitcoin from being moved unless it is a legitimate owner, but here is an electronic signature with a private key. Bitcoin takes advantage of the characteristics of public key cryptography and applies digital signatures to prove ownership. The private key is treated as WIF (Wallet Import Format) format. There is also a compressed WIF format, but details are omitted. (By the way, the above app uses compressed WIF format)
create-tx.py is an application that creates a signed transaction and sends it to the network.
When I actually made something that works like this, I learned sensuously that the private key and address can be managed separately. Since the app I made this time was not supposed to be released in this way, I think that the license is not specified and there are various points of interest. (Can I add or change it later?) If you have any advice, such as something strange here or something like this, please comment.
Mastering Bitcoin national translation PDF storage https://www.bitcoinbook.info/translations-of-mastering-bitcoin/
pycoin github repository https://github.com/richardkiss/pycoin
Recommended Posts