0145 - Final - Standards - Jan. 30, 2016 (10 years, 5 months ago)
30
2016
BIP: 145
Layer: API/RPC
Title: getblocktemplate Updates for Segregated Witness
Author: Luke Dashjr <[email protected]>
Comments-Summary: No comments yet.
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP 145
Status: Final
Type: Standards Track
Created: 2016-01-30
License: BSD-2-Clause
OPL
This BIP describes modifications to the getblocktemplate JSON-RPC call ( BIP 22 ) to support segregated witness as defined by BIP 141 .
The template Object is revised to include a new key:
| template | |||
|---|---|---|---|
|
Key |
Required |
Type |
Description |
|
weightlimit |
No |
Number |
total weight allowed in blocks |
The '!' rule prefix MUST be enabled on the "segwit" rule for templates including transactions with witness data. In particular, note that even if the client's "rules" list lacks "segwit", server MAY support old miners by producing a witness-free template and omitting the '!' rule prefix for "segwit" in the template's "rules" list. If the GBT server does not support producing witness-free templates after its activation, it must also use the '!' rule prefix in the "vbavailable" list prior to activation.
The Objects listed in the response's "transactions" key is revised to include these keys:
| template "transactions" element | ||
|---|---|---|
|
Key |
Type |
Description |
|
txid |
String |
transaction id encoded in hexadecimal; required for transactions with witness data |
|
weight |
Number |
numeric weight of the transaction, as counted for purposes of the block's weightlimit; if key is not present, weight is unknown and clients MUST NOT assume it is zero, although they MAY choose to calculate it themselves |
|
hash |
String |
reversed hash of complete transaction (with witness data included) encoded in hexadecimal |
Transactions with witness data may only be included if the template's "rules" list (see BIP 9 ) includes "segwit".
For templates with "segwit" enabled as a rule, the "sigoplimit" and "sigops" keys must use the new values as calculated in BIP 141 .
When block assembly is done without witness transactions, no changes are made by this BIP, and it should be assembled as previously.
When witness transactions are included in the block, the primary merkle root MUST be calculated with those transactions' "txid" field instead of "hash". A secondary merkle root MUST be calculated as per BIP 141's commitment structure specification to be inserted into the generation (coinbase) transaction.
Servers MUST NOT include a commitment in the "coinbasetxn" key on the template. Clients MUST insert the commitment as an additional output at the end of the final generation (coinbase) transaction. Only if the template includes a "mutable" key (see BIP 23 Mutations ) including "generation", the client MAY in that case place the commitment output in any position it chooses, provided that no later output matches the commitment pattern.
Segregated witness substantially changes the structure of blocks, so the previous getblocktemplate specification is no longer sufficient. It additionally also adds a new way of counting resource limits, and so GBT must be extended to convey this information correctly as well.
Why doesn't "weightlimit" simply redefine the existing "sizelimit"?
Why is "sigoplimit" redefined instead of a new "sigopweightlimit" being added?
Why is "sigoplimit" divided by 4?
Why is the witness commitment required to be added to the end of the generation transaction rather than anywhere else?
Why shouldn't the server simply add the commitment upfront in the "coinbasetxn", and simply send the client stripped transaction data?
This BIP is dual-licensed under the Open Publication License and BSD 2-clause license.