A tutorial on the use of cottage currency trading signature + public key development

Source: Internet
Author: User
Tags valid

Blockchain Enthusiast (qq:53016353)

If you have been exposed to the cottage for long enough, you must have heard that the cottage is a blockchain, a chunk contains many trades, and the trades are all chained together. So, what is the details of the specific transaction? The usual technical documentation is full of terminology, and even the Nakamoto white paper is difficult to integrate directly with the practice, and I have recently studied it in a simple metaphor to explain

Let's say you have three address a,b,c in your wallet. You have 1 coins in address A, you send the currency to address B in the Wallet software, you can find the transaction on the blockchain, it may be called the trade armor. And then you made a deal. B, send the coin from address B to address C. Assuming that the handling fee is 0.0001 coins, each time you have spent 0.0001 currency as a handling fee, the transaction A is confirmed after the address B is 0.9999 coins, and the transaction B is confirmed that the address C is 0.9998 coins


Deal A: Address a 1BTC, address b 0.9999 BTC, handling fee 0.0001
Trade B: Address b 0.9999BTC, address C 0.9998 BTC, handling fee 0.0001


It's best to understand the analogy with books


The book is a blockchain, and every page of the ledger is a chunk of paper, which in turn binds together to form an entire ledger. Each page is covered with one after another money order (trading)


If you look closely at the remittance transaction B (Transfer 0.9998 currency from address B to address C and pay 0.0001 handling fee), you will find that the transaction B is made up of two major parts, the former part can be called the Payment information (input), the latter part can be called the collection information (output)


According to the usual habit of filling in the bank, the payment information in the account name (that is, address B) and the account holder signed (authorized transaction), and the collection information should be filled in the amount and the beneficiary account name (i.e. address C). In fact, the cottage currency transaction is roughly the same, with only a slight difference


Trading Armor
Payment Information: Signature + Public Key A (signature is equivalent to stamp, is generated with the personal seal (private key) of address A, and the public key of address A can be used to let others verify that the chapter is valid (private key public key cryptography principle is everywhere))
Collection information: 0.9999 (amount) + address B + redemption conditions (here The redemption conditions indicate the future to spend address B's currency needs to meet what conditions, detailed below)


Trade b
Payment Information: Signature + public key B
Collection information: 0.9998 + address C + Redemption conditions


Trade C
Payment Information: Signature + public key C
Collection information: 0.9997 + address D + Redemption conditions




There are a few points and the bank money order different places


First, each money order is spent in the payment address of the previous remittance, so that all transactions are linked together, and if you want to thoroughly verify that a transaction is effective, it is necessary to follow this chain back to the most primitive mining output transaction (before the deal a other transaction), This ensures that as long as the user has a full copy of the blockchain (that is, the 60G data of the current full node), it is possible to independently verify the validity of any transaction.


Second, each remittance can only be spent entirely on all the coins in the expense account. Take the transaction B as an example, the original address B is empty after the remittance is completed. If you only want to transfer half of the money to address C, the remaining half will be in the collection information to fill in an additional account address E, that is, the so-called change address


Third, the total remittance amount is less than the part of address B is the handling fee. If there are 0.9999 coins in address B, the amount of the remittance to address C is 0.9998 coins, the difference between 0.0001 is the miner's handling fee.


Finally, verifying that the transaction B is valid is guaranteed by the redemption conditions in the collection information of the previous transaction, which is a transaction. There are a number of rules, and the two most common are the signatures that provide the payment address (P2PKH) and a hash of the program (P2SH, which involves hashing, a means of forgery)






If you fully understand, then you understand the function of the cottage currency trading, close to the level of the core programmer, later encountered a lot of nouns such as scriptsig (signature + public key) and Scriptpubkey (redemption rules) and so you can easily know which part of the money order


Here is a more complex concept of signature, I separately analysis, this signature and the recent Martian text isolation witness has a close relationship

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.