{"number":145,"title":"getblocktemplate Updates for Segregated Witness","authors":["Luke Dashjr"],"status":"Deployed","type":"Specification","layer":"API/RPC","created":"2016-01-30","license":"BSD-2-Clause OR OPUBL-1.0","requires":[],"replaces":[],"replacedBy":[],"discussion":[],"abstract":"This BIP describes modifications to the getblocktemplate JSON-RPC call ( BIP 22 ) to support segregated witness as defined by BIP 141 .","eli5":"Updates getblocktemplate, the interface miners and mining pools use to request a block to work on, so it supports SegWit. Without this, miners could not build blocks that include SegWit transactions and their separate witness data.","categories":["segwit","consensus"],"filename":"bip-0145.mediawiki","githubUrl":"https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki","format":"mediawiki","readingMinutes":4,"inbound":1,"revisions":22,"impact":58,"core":false,"references":[9,22,23,141],"lastModified":"2026-02-27","html":"<h2 id=\"abstract\">Abstract</h2>\n<p>This BIP describes modifications to the getblocktemplate JSON-RPC call (<a href=\"/bip/22\">BIP 22</a>) to support segregated witness as defined by <a href=\"/bip/141\">BIP 141</a>.</p>\n<h2 id=\"specification\">Specification</h2>\n<h3 id=\"block-template\">Block Template</h3>\n<p>The template Object is revised to include a new key:</p>\n<div class=\"table-wrap\"><table><tbody><tr><th colspan=4>template</th></tr><tr><th>Key</th><th>Required</th><th>Type</th><th>Description</th></tr><tr><td>weightlimit</td><td>No</td><td>Number</td><td>total weight allowed in blocks</td></tr></tbody></table></div>\n<p>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.</p>\n<h4 id=\"transactions-object-format\">Transactions Object Format</h4>\n<p>The Objects listed in the response's \"transactions\" key is revised to include these keys:</p>\n<div class=\"table-wrap\"><table><tbody><tr><th colspan=3>template \"transactions\" element</th></tr><tr><th>Key</th><th>Type</th><th>Description</th></tr><tr><td>txid</td><td>String</td><td>transaction id encoded in hexadecimal; required for transactions with witness data</td></tr><tr><td>weight</td><td>Number</td><td>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</td></tr><tr><td>hash</td><td>String</td><td>reversed hash of complete transaction (with witness data included) encoded in hexadecimal</td></tr></tbody></table></div>\n<p>Transactions with witness data may only be included if the template's \"rules\" list (see <a href=\"/bip/9#getblocktemplate-changes\">BIP 9</a>) includes \"segwit\".</p>\n<h3 id=\"sigops\">Sigops</h3>\n<p>For templates with \"segwit\" enabled as a rule, the \"sigoplimit\" and \"sigops\" keys must use the new values as calculated in <a href=\"/bip/141#sigops\">BIP 141</a>.</p>\n<h3 id=\"block-assembly-with-witness-transactions\">Block Assembly with Witness Transactions</h3>\n<p>When block assembly is done without witness transactions, no changes are made by this BIP, and it should be assembled as previously.</p>\n<p>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 <a href=\"/bip/141#commitment-structure\">BIP 141's commitment structure specification</a> to be inserted into the generation (coinbase) transaction.</p>\n<p>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 <a href=\"/bip/23#mutations\">BIP 23 Mutations</a>) 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.</p>\n<h2 id=\"motivation\">Motivation</h2>\n<p>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.</p>\n<h2 id=\"rationale\">Rationale</h2>\n<p>Why doesn't \"weightlimit\" simply redefine the existing \"sizelimit\"?</p>\n<ul><li>\n\"sizelimit\" is already enforced by clients by counting the sum of bytes in transactions' \"data\" keys.\n</li></ul>\n<ul><li>\nServers may wish to limit the overall size of a block, independently from the \"weight\" of the block.\n</li></ul>\n<p>Why is \"sigoplimit\" redefined instead of a new \"sigopweightlimit\" being added?</p>\n<ul><li>\nThe old limit was already arbitrarily defined, and could not be counted by clients on their own anyway. The concept of \"sigop weight\" is merely a change in the arbitrary formula used.\n</li></ul>\n<p>Why is \"sigoplimit\" divided by 4?</p>\n<ul><li>\nTo resemble the previous values. (FIXME: is this a good reason? maybe we shouldn't divide it?)\n</li></ul>\n<p>Why is the witness commitment required to be added to the end of the generation transaction rather than anywhere else?</p>\n<ul><li>\nServers which do not allow modification of the generation outputs ought to be checking this as part of the validity of submissions. By requiring a specific placement, they can simply strip the commitment and do a byte-for-byte comparison of the outputs. Placing it at the end avoids the possibility of a later output matching the pattern and overriding it.\n</li></ul>\n<p>Why shouldn't the server simply add the commitment upfront in the \"coinbasetxn\", and simply send the client stripped transaction data?</p>\n<ul><li>\nIt would become impossible for servers to specify only \"coinbasevalue\", since clients would no longer have the information required to construct the commitment.\n</li></ul>\n<ul><li>\ngetblocktemplate is intended to be a *decentralised* mining protocol, and allowing clients to be blinded to the content of the block works contrary to that purpose.\n</li></ul>\n<ul><li>\nBIP 23's \"transactions\" mutations allow the client to modify the transaction-set on their own, which is impossible without the complete transaction data.\n</li></ul>\n<h2 id=\"reference-implementation\">Reference Implementation</h2>\n<ul><li>\n<a href=\"https://github.com/bitcoin/libblkmaker/tree/segwit\">libblkmaker</a>\n</li></ul>\n<ul><li>\n<a href=\"https://github.com/luke-jr/eloipool/tree/segwit\">Eloipool</a>\n</li></ul>\n<ul><li>\n<a href=\"https://github.com/bitcoin/bitcoin/pull/7404/files\">Bitcoin Core</a>\n</li></ul>\n<h2 id=\"see-also\">See Also</h2>\n<ul><li>\n<a href=\"/bip/9\">BIP 9: Version bits with timeout and delay</a>\n</li></ul>\n<ul><li>\n<a href=\"/bip/22\">BIP 22: getblocktemplate - Fundamentals</a>\n</li></ul>\n<ul><li>\n<a href=\"/bip/23\">BIP 23: getblocktemplate - Pooled Mining</a>\n</li></ul>\n<ul><li>\n<a href=\"/bip/141\">BIP 141: Segregated Witness (Consensus layer)</a>\n</li></ul>\n<h2 id=\"copyright\">Copyright</h2>\n<p>This BIP is dual-licensed under the Open Publication License and BSD 2-clause license.</p>","toc":[{"id":"abstract","title":"Abstract","level":2},{"id":"specification","title":"Specification","level":2},{"id":"block-template","title":"Block Template","level":3},{"id":"transactions-object-format","title":"Transactions Object Format","level":4},{"id":"sigops","title":"Sigops","level":3},{"id":"block-assembly-with-witness-transactions","title":"Block Assembly with Witness Transactions","level":3},{"id":"motivation","title":"Motivation","level":2},{"id":"rationale","title":"Rationale","level":2},{"id":"reference-implementation","title":"Reference Implementation","level":2},{"id":"see-also","title":"See Also","level":2},{"id":"copyright","title":"Copyright","level":2}],"history":{"totalCommits":22,"firstCommit":"2016-02-09T05:12:38+00:00","lastUpdated":"2026-02-27T14:12:41-08:00","events":[{"sha":"b3a069464a8879dd858c392a788c9d19a9f7a075","date":"2026-02-27T14:12:41-08:00","author":"Murch","message":"Fix other broken anchors","url":"https://github.com/bitcoin/bips/commit/b3a069464a8879dd858c392a788c9d19a9f7a075","kind":"edit"},{"sha":"8586c32fa26de94b6a8a91b30a9e3d93f8ee0555","date":"2025-10-22T21:32:52+02:00","author":"Tim Ruffing","message":"process: Use \"official\" SPDX identifiers","url":"https://github.com/bitcoin/bips/commit/8586c32fa26de94b6a8a91b30a9e3d93f8ee0555","kind":"edit"},{"sha":"2885f13d3f37890e328683166dbcbc60b488d13a","date":"2025-10-22T20:02:57+10:00","author":"Anthony Towns","message":"Convert licenses to SPDX codes","url":"https://github.com/bitcoin/bips/commit/2885f13d3f37890e328683166dbcbc60b488d13a","kind":"rename"},{"sha":"24e96e870fffaa257b465ce1f0370c14aac588e8","date":"2025-10-08T14:59:36-07:00","author":"Murch","message":"process: Created ↦ Assigned","url":"https://github.com/bitcoin/bips/commit/24e96e870fffaa257b465ce1f0370c14aac588e8","kind":"edit"},{"sha":"5207ef92a52d0b8902895b0dbb40823a4d698ec9","date":"2025-04-11T20:08:17-07:00","author":"Murch","message":"process: Author ↦ Authors","url":"https://github.com/bitcoin/bips/commit/5207ef92a52d0b8902895b0dbb40823a4d698ec9","kind":"edit"},{"sha":"59730dec4fb641a41589aa1b91d3c452f13e0e36","date":"2025-04-11T20:05:13-07:00","author":"Murch","message":"process: Remove Comments-URI and -Summary","url":"https://github.com/bitcoin/bips/commit/59730dec4fb641a41589aa1b91d3c452f13e0e36","kind":"edit"},{"sha":"a233bde4af52c6a11269e2e6dd9707abce441ffe","date":"2025-04-11T18:19:21-07:00","author":"Murch","message":"process: Standards Track ↦ Specification","url":"https://github.com/bitcoin/bips/commit/a233bde4af52c6a11269e2e6dd9707abce441ffe","kind":"edit"},{"sha":"5d3ceb37734f80b2ec206fc94245e3bfd6d5b0f0","date":"2025-04-11T18:08:44-07:00","author":"Murch","message":"process: Final/Active ↦ Deployed","url":"https://github.com/bitcoin/bips/commit/5d3ceb37734f80b2ec206fc94245e3bfd6d5b0f0","kind":"status"},{"sha":"41e06840ebb7b5459bb77707e427fa2687831ed4","date":"2017-08-30T15:37:48+08:00","author":"Johnson Lau","message":"Promote BIP 145 to Final","url":"https://github.com/bitcoin/bips/commit/41e06840ebb7b5459bb77707e427fa2687831ed4","kind":"status"},{"sha":"959fecc15bdad070afa63455468b1dba54655fa6","date":"2016-11-30T09:47:31+00:00","author":"Luke Dashjr","message":"Promote BIP 2 Draft->Active, and implement it","url":"https://github.com/bitcoin/bips/commit/959fecc15bdad070afa63455468b1dba54655fa6","kind":"status"},{"sha":"72f18918a8ae655212ea2700b30f0dc4d758b843","date":"2016-11-30T09:45:33+00:00","author":"Luke Dashjr","message":"Promote BIP 123 Draft->Active, and implement it","url":"https://github.com/bitcoin/bips/commit/72f18918a8ae655212ea2700b30f0dc4d758b843","kind":"status"},{"sha":"d8928eb85a641b3ad5efa956a512adb88a02d10b","date":"2016-07-23T20:35:56+00:00","author":"Luke Dashjr","message":"BIP 145: Update s/cost/weight/","url":"https://github.com/bitcoin/bips/commit/d8928eb85a641b3ad5efa956a512adb88a02d10b","kind":"edit"},{"sha":"ed0f8da4ad97703f1c57919303da082810885fb7","date":"2016-04-23T20:32:59+00:00","author":"Luke Dashjr","message":"BIP 22 & 145: Use simple Yes/No rather than templates (which don't work on GitHub)","url":"https://github.com/bitcoin/bips/commit/ed0f8da4ad97703f1c57919303da082810885fb7","kind":"edit"},{"sha":"162e2e002568dc8f1b4a85180d903366f74f40c4","date":"2016-05-11T17:45:08+00:00","author":"Luke Dashjr","message":"Replace \"rules/force\" mutation with a \"cannot be ignored\" prefix to rule names","url":"https://github.com/bitcoin/bips/commit/162e2e002568dc8f1b4a85180d903366f74f40c4","kind":"edit"},{"sha":"cc4a94c1c04284fc8eca3f83b8d139711fa2a345","date":"2016-04-25T00:18:39+00:00","author":"Luke Dashjr","message":"BIP 9 & 145: rules/force mutation","url":"https://github.com/bitcoin/bips/commit/cc4a94c1c04284fc8eca3f83b8d139711fa2a345","kind":"edit"},{"sha":"31c45b611d805a349bc27552e85ba876a5af34ba","date":"2016-04-23T20:32:59+00:00","author":"Luke Dashjr","message":"BIP 9, 22 & 145: Use simple Yes/No rather than templates (which don't work on GitHub)","url":"https://github.com/bitcoin/bips/commit/31c45b611d805a349bc27552e85ba876a5af34ba","kind":"edit"},{"sha":"4683a9b71424bac4d43af2236f36fdc2b0c9f470","date":"2016-04-23T20:20:13+00:00","author":"Luke Dashjr","message":"BIP 9 (& 145): Switch to rules/vbavailable/vbrequired GBT interface","url":"https://github.com/bitcoin/bips/commit/4683a9b71424bac4d43af2236f36fdc2b0c9f470","kind":"edit"},{"sha":"2fa7fb9b5cf9a4dbe2affe44267014fc486cbcf6","date":"2016-03-30T22:43:33+00:00","author":"Luke Dashjr","message":"BIP 141: Specify VB name","url":"https://github.com/bitcoin/bips/commit/2fa7fb9b5cf9a4dbe2affe44267014fc486cbcf6","kind":"edit"},{"sha":"161b39fa687d4716cd54953e840511ebba45899d","date":"2016-03-30T22:42:42+00:00","author":"Luke Dashjr","message":"BIP 145: Update for BIP 9","url":"https://github.com/bitcoin/bips/commit/161b39fa687d4716cd54953e840511ebba45899d","kind":"edit"},{"sha":"a5447e0c4b219acbbc1e09ccd9419e8dff94f1e8","date":"2016-03-30T21:43:36+00:00","author":"Luke Dashjr","message":"BIP 141 & 145: Clarify sigop interaction","url":"https://github.com/bitcoin/bips/commit/a5447e0c4b219acbbc1e09ccd9419e8dff94f1e8","kind":"edit"},{"sha":"42777fed36a9482fc0d35733204b2fdaecec36b1","date":"2016-02-09T05:26:28+00:00","author":"Luke Dashjr","message":"bip-0145: Remove incomplete thought","url":"https://github.com/bitcoin/bips/commit/42777fed36a9482fc0d35733204b2fdaecec36b1","kind":"edit"},{"sha":"421577d6cf26bb21bebcb4da5f04e183d2859d0a","date":"2016-02-09T05:12:38+00:00","author":"Luke Dashjr","message":"Assign BIP 145: getblocktemplate Updates for Segregated Witness","url":"https://github.com/bitcoin/bips/commit/421577d6cf26bb21bebcb4da5f04e183d2859d0a","kind":"edit"}]}}