Skip to content

Commit

Permalink
Adds creditpool data to coinbase tx python's binding (message.py)
Browse files Browse the repository at this point in the history
It also fixes functional tests 'feature_nulldummy.py', 'feature_llmq_is_cl_conflicts.py'
  • Loading branch information
knst committed Sep 29, 2022
1 parent a3a10a2 commit 1664632
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions test/functional/feature_nulldummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from test_framework.messages import CTransaction
from test_framework.script import CScript
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error
from test_framework.util import assert_equal, assert_raises_rpc_error, get_bip9_status


NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero) (code 64)"
Expand Down Expand Up @@ -88,7 +88,11 @@ def run_test(self):

def block_submit(self, node, txs, accept = False):
dip4_activated = self.lastblockheight + 1 >= 432
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1, dip4_activated=dip4_activated), self.lastblocktime + 1)
print("bip9")
info = node.getblockchaininfo()
print(info['bip9_softforks'])
dip27_activated = get_bip9_status(self.nodes[0], 'dip0027-asset-locks')['status'] == 'active'
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1, dip4_activated=dip4_activated, dip27_activated=dip27_activated), self.lastblocktime + 1)
block.nVersion = 4
for tx in txs:
tx.rehash()
Expand Down
5 changes: 3 additions & 2 deletions test/functional/test_framework/blocktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def script_BIP34_coinbase_height(height):
return CScript([CScriptNum(height)])


def create_coinbase(height, pubkey=None, dip4_activated=False):
def create_coinbase(height, pubkey=None, dip4_activated=False, dip27_activated=False):
"""Create a coinbase transaction, assuming no miner fees.
If pubkey is passed in, the coinbase output will be a P2PK output;
Expand All @@ -65,7 +65,8 @@ def create_coinbase(height, pubkey=None, dip4_activated=False):
if dip4_activated:
coinbase.nVersion = 3
coinbase.nType = 5
cbtx_payload = CCbTx(2, height, 0, 0)
cbtx_version = 3 if dip27_activated else 2
cbtx_payload = CCbTx(cbtx_version, height, 0, 0, 0)
coinbase.vExtraPayload = cbtx_payload.serialize()
coinbase.calc_sha256()
return coinbase
Expand Down
11 changes: 9 additions & 2 deletions test/functional/test_framework/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,9 @@ def __repr__(self):


class CCbTx:
__slots__ = ("version", "height", "merkleRootMNList", "merkleRootQuorums")
__slots__ = ("version", "height", "merkleRootMNList", "merkleRootQuorums", "lockedAmount")

def __init__(self, version=None, height=None, merkleRootMNList=None, merkleRootQuorums=None):
def __init__(self, version=None, height=None, merkleRootMNList=None, merkleRootQuorums=None, lockedAmount=None):
self.set_null()
if version is not None:
self.version = version
Expand All @@ -1046,18 +1046,23 @@ def __init__(self, version=None, height=None, merkleRootMNList=None, merkleRootQ
self.merkleRootMNList = merkleRootMNList
if merkleRootQuorums is not None:
self.merkleRootQuorums = merkleRootQuorums
if lockedAmount is not None:
self.lockedAmount = lockedAmount

def set_null(self):
self.version = 0
self.height = 0
self.merkleRootMNList = None
self.lockedAmount = 0

def deserialize(self, f):
self.version = struct.unpack("<H", f.read(2))[0]
self.height = struct.unpack("<i", f.read(4))[0]
self.merkleRootMNList = deser_uint256(f)
if self.version >= 2:
self.merkleRootQuorums = deser_uint256(f)
if self.version >= 3:
self.lockedAmount = struct.unpack("<q", f.read(8))[0]

def serialize(self):
r = b""
Expand All @@ -1066,6 +1071,8 @@ def serialize(self):
r += ser_uint256(self.merkleRootMNList)
if self.version >= 2:
r += ser_uint256(self.merkleRootQuorums)
if self.version >= 3:
r += struct.pack("<q", self.lockedAmount)
return r


Expand Down

0 comments on commit 1664632

Please sign in to comment.