In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the knowledge points of Bitcoin wallet isolation authentication development". In daily operation, I believe many people have doubts about bitcoin wallet isolation authentication development knowledge points. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "what are the knowledge points of Bitcoin wallet isolation authentication development?" Next, please follow the editor to study!
Basic isolation authentication support
The wallet must implement all the features in this section in order to be considered segwit compliant at the basic level:
Send to P2SH
Segwit-compatible wallets must support pay-to-script-hash (BIP16) and its address format (BIP13).
For payment, the wallet must be able to correctly translate the given P2SH address to scriptPubKey and create a transaction.
In order to receive payments, the wallet must be able to create P2SH addresses based on P2WPKH scripts (defined below) and be able to recognize payments to those addresses.
This is a mandatory requirement, even if the wallet only accepts single signature payment.
Create a P2SH-P2WPKH address
The P2SH-P2WPKH address is equivalent to the original single-signed P2PKH address of Bitcoin (an address with a prefix of 1).
Like any other P2SH address, the P2SH-P2WPKH address has a prefix of 3.
Before using P2SH-P2WPKH UTXO and exposing redeemScript, P2SH-P2WPKH addresses cannot be distinguished from non-segwit P2SH addresses (for example, non-segwit multi-signed addresses).
When only 1 public key is used to receive payments (such as P2PKH), the P2SH-P2WPKH address should be used.
P2SH-P2WPKH uses the same public key format as P2PKH, with one very important exception: the public key used in P2SH-P2WPKH must be compressed, that is, the size is 33 bytes, starting with 0x02 or 0x03. The use of any other format, such as an uncompressed public key, may result in irrevocable financial losses.
Create a P2SH-P2WPKH address:
1. Calculates the RIPEMD160 of the SHA256 of the public key (keyhash). Although the keyhash formula is the same as P2PKH, you should avoid reusing keyhash for better privacy and prevent accidental use of uncompressed keys.
The 2.P2SH redeemScript is always 22 bytes. It starts with OP_0, followed by keyhash's canonical push (such as 0x0014 {20-byte keyhash}).
3. Like other P2SH, scriptPubKey is the OP_HASH160 hash260 (redeemScript) OP_EQUAL, and the address is the corresponding P2SH address with a prefix of 3.
Transaction serialization
Segwit-compatible wallets must support the original transaction format, such as nVersion | txins | txouts | nLockTime.
Segwit-compatible wallets must also support new serialization formats, such as nVersion | marker | flag | txins | txouts | witness | nLockTime.
The format of nVersion,txins,txouts and nLockTime is the same as the original format.
Marker must be 0x00.
Flag must be 0x01.
Witness is the serialization of all witness data for a transaction.
Each txin is associated with a witness field. As a result, there is no indication of the number of evidence fields displayed because it is defaulted by the number of txins.
Each witness field begins with a compactSize integer to indicate the number of stack items for the corresponding txin. Then the number of witness stack items (if any) for the corresponding txin.
Each witness stack item begins with compactSize integer to indicate the number of bytes of the item.
If txin is not associated with any witness data, its corresponding witness field is exactly 0x00, indicating that the number of witness stack items is zero.
If none of the txins in the transaction is associated with any witness data, the transaction must be serialized in the original transaction format, excluding marker, flag, witness. For example, if no txins comes from segwit UTXO, it must be serialized in the original transaction format. (except for coinbase transactions)
You can find an example of transaction serialization in the examples section of BIP143. Wallet developers can use these examples to test whether their implementation correctly parses the new serialization format.
Transaction ID
Under segwit, there will be 2 ID per transaction.
The definition of txid remains the same: double SHA256 in the original serialized format.
A new wtxid is defined, which is a double SHA256 with a new serialization format for witness data.
If the transaction does not have any witness data, its wtxid is the same as txid.
Txid is still the primary identifier for the deal:
When referencing the previous output, it must be used in txin.
If the wallet or service is currently using txid to identify transactions, it indicates that it will continue to use segwit.
Signature Generation and Verification of P2SH-P2WPKH
For non-segwit UTXO consumption, the signature generation algorithm remains the same.
For P2SH-P2WPKH consumption:-scriptSig must contain only one redeemScript.
The corresponding witness field must contain 2 items, with the signature followed by the public key.
A new signature generation algorithm for segwit scripts is described in BIP143 (see end of the article). Developers should follow the instructions carefully and use the P2SH-P2WPKH examples in BIP143 to ensure that they can recreate the sighash.
The BIP143 signature generation algorithm covers the input values spent and simplifies the design of air-gapped lightweight wallets and hardware wallets.
Note that there are always 26 bytes of scriptCode for P2SH redeemScript, including leading size bytes, such as 0x1976a914 {20-byte keyhash} 88ac, not redeemScript or scriptPubKey.
Example.
Network services (optional)
If the wallet sends and receives transactions over a peer-to-peer network, network services are required.
Nodes that support Segwit will indicate that they can provide witness through the service bit: NODE_WITNESS= (1
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.