wiki commit

This commit is contained in:
1HXb9KMAtwNJqz4egi6hJx08EQgJajiBTH
2020-01-06 16:55:18 -05:00
committed by buwiki
parent 5ef58782d6
commit 010556df4d
5 changed files with 97 additions and 124 deletions
+23 -34
View File
@@ -2,7 +2,7 @@
BIP: 64
Layer: Peer Services
Title: getutxo message
Author: Mike Hearn <hearn@vinumeris.com>
Author: Mike Hearn &lt;hearn@vinumeris.com&gt;
Comments-Summary: No comments yet.
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0064
Status: Draft
@@ -10,11 +10,11 @@
Created: 2014-06-10
</pre>
==Abstract==
## Abstract
This document describes a small P2P protocol extension that performs UTXO lookups given a set of outpoints.
==Motivation==
## Motivation
All full Bitcoin nodes maintain a database called the unspent transaction output set. This set is
how double spending is checked for: to be valid a transaction must identify unspent outputs in this
@@ -32,50 +32,39 @@ Another example of when this data can be useful is for performing floating fee c
SPV wallet. This use case requires some other changes to the Bitcoin protocol however, so we will
not dwell on it here.
==Specification==
## Specification
Two new messages are defined. The "getutxos" message has the following structure:
{|class="wikitable"
! Field Size !! Description !! Data type !! Comments
|-
| 1 || check mempool || bool || Whether to apply mempool transactions during the calculation, thus exposing their UTXOs and removing outputs that they spend.
|-
| ? || outpoints || vector<COutPoint> || The list of outpoints to be queried. Each outpoint is serialized in the same way it is in a tx message.
|}
| Field Size | Description | Data type | Comments |
|--|--|--|--|
| 1 | check mempool | bool | Whether to apply mempool transactions during the calculation, thus exposing their UTXOs and removing outputs that they spend.
| ? | outpoints | vector&lt;COutPoint&gt; | The list of outpoints to be queried. Each outpoint is serialized in the same way it is in a tx message.
The response message "utxos" has the following structure:
{|class="wikitable"
! Field Size !! Description !! Data type !! Comments
|-
| 4 || chain height || uint32 || The height of the chain at the moment the result was calculated.
|-
| 32 || chain tip hash || uint256 || Block hash of the top of the chain at the moment the result was calculated.
|-
| ? || hit bitmap || byte[] || An array of bytes encoding one bit for each outpoint queried. Each bit indicates whether the queried outpoint was found in the UTXO set or not.
|-
| ? || result utxos || result[] || A list of result objects (defined below), one for each outpoint that is unspent (i.e. has a bit set in the bitmap).
|}
| Field Size | Description | Data type | Comments |
|--|--|--|--|
| 4 | chain height | uint32 | The height of the chain at the moment the result was calculated.
| 32 | chain tip hash | uint256 | Block hash of the top of the chain at the moment the result was calculated.
| ? | hit bitmap | byte[] | An array of bytes encoding one bit for each outpoint queried. Each bit indicates whether the queried outpoint was found in the UTXO set or not.
| ? | result utxos | result[] | A list of result objects (defined below), one for each outpoint that is unspent (i.e. has a bit set in the bitmap).
The result object is defined as:
{|class="wikitable"
! Field Size !! Description !! Data type !! Comments
|-
| 4 || tx version || uint32 || The version number of the transaction the UTXO was found in.
|-
| 4 || height || uint32 || The height of the block containing the defining transaction, or 0x7FFFFFFF if the tx is in the mempool.
|-
| ? || output || CTxOut || The output itself, serialized in the same way as in a tx message.
|}
| Field Size | Description | Data type | Comments |
|--|--|--|--|
| 4 | tx version | uint32 | The version number of the transaction the UTXO was found in.
| 4 | height | uint32 | The height of the block containing the defining transaction, or 0x7FFFFFFF if the tx is in the mempool.
| ? | output | CTxOut | The output itself, serialized in the same way as in a tx message.
==Backward compatibility==
## Backward compatibility
Nodes indicate support by advertising a protocol version above 70003 and by setting a new
NODE_GETUTXO flag in their nServices field, which has a value of 2 (the second bit of the field).
==Authentication==
## Authentication
The UTXO set is not currently authenticated by anything. There are proposals to resolve this by
introducing a new consensus rule that commits to a root hash of the UTXO set in blocks, however this
@@ -101,6 +90,6 @@ Querying multiple nodes and combining their answers can be a partial solution to
nothing authenticates the Bitcoin P2P network a man in the middle could still yield incorrect
results.
==Implementation==
## Implementation
https://github.com/bitcoin/bitcoin/pull/4351/files