比特币中常用的交易类型(Transaction Types)

时间:2022-04-13 13:51:33

Bitcoin的Script

比特币中常用的交易类型

P2PKH – Pay to Public Key Hash

This is the most common type of transaction. To gain access to its outputs, the recipient needs to prove that he can sign a message with the private key (S) which corresponds to public key (P) that hashes to H.

To create a transaction, the payer needs to know the recipient’s address. P2PKH addresses are the Base58Check encoding of version number 0, a hash of the recipient’s public key (H), and a checksum. Due to the way they are constructed,

all P2PKH addresses start with the character “1” .
Example: 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2

P2PK – Pay to Public Key

With this transaction type, the public key itself is stored in the locking script,
rather than a public-key-hash.

P2PK与P2PKH相比缺点是会暴露公钥

OP_RETURN – Data Output

P2SH – Pay to Script Hash

To gain access to outputs sent via P2SH, the recipient must provide a script which matches the given hash and data which makes that script evaluate to True. This allows the recipient to implement various unusual security schemes.

For example, one can thus send bitcoins to multi-signature addresses, which require the signatures of multiple people to spend the outputs.

P2SH addresses are the Base58Check encoding of version number 5, a hash
of the recipient’s public key (H), and a checksum. Due to the way they are constructed,

all P2SH addresses start with the character “3” .
Example: 3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX