Skip to content

Commit

Permalink
GBT server: Remove commitment output from coinbasetxn since BIP 145 r…
Browse files Browse the repository at this point in the history
…equires the server omit it
  • Loading branch information
luke-jr committed Nov 22, 2016
1 parent f140d8d commit 7f31892
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions bitcoin/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from base58 import b58decode
from util import dblsha

WitnessMagic = b'\xaa\x21\xa9\xed'

def _Address2PKH(addr):
try:
addr = b58decode(addr, 25)
Expand Down
4 changes: 1 addition & 3 deletions eloipool.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,14 @@ def RaiseRedFlags(reason):
pass


from bitcoin.script import BitcoinScript
from bitcoin.script import BitcoinScript, WitnessMagic
from bitcoin.txn import Txn
from base58 import b58decode
from binascii import b2a_hex
from struct import pack
import subprocess
from time import time

WitnessMagic = b'\xaa\x21\xa9\xed'

def makeCoinbaseTxn(coinbaseValue, useCoinbaser = True, prevBlockHex = None, witness_commitment = NotImplemented):
if witness_commitment is NotImplemented:
raise NotImplementedError
Expand Down
4 changes: 4 additions & 0 deletions jsonrpc_getblocktemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from binascii import b2a_hex
from bitcoin.script import BitcoinScript, WitnessMagic
from copy import deepcopy
from jsonrpcserver import JSONRPCHandler
from time import time
Expand Down Expand Up @@ -85,6 +86,9 @@ def doJSON_getblocktemplate(self, params):
rv['target'] = '%064x' % (target,)
t = deepcopy(merkleTree.data[0])
t.setCoinbase(cb)
if not merkleTree.witness_commitment is None:
assert t.outputs[-1] == (0, BitcoinScript.commitment(WitnessMagic + merkleTree.witness_commitment))
t.outputs.pop()
t.assemble()
txno = {}
txno['data'] = b2a_hex(t.data).decode('ascii')
Expand Down

0 comments on commit 7f31892

Please sign in to comment.