Decred: test_010_txn_size

This commit is contained in:
tecnovert
2024-05-20 18:27:47 +02:00
parent 446d6fe357
commit aa1e1fd79c
3 changed files with 119 additions and 2 deletions

View File

@@ -206,6 +206,14 @@ class DCRInterface(Secp256k1Interface):
def txoType():
return CTxOut
@staticmethod
def xmr_swap_a_lock_spend_tx_vsize() -> int:
return 327
@staticmethod
def xmr_swap_b_lock_spend_tx_vsize() -> int:
return 224
@staticmethod
def getExpectedSequence(lockType: int, lockVal: int) -> int:
ensure(lockVal >= 1, 'Bad lockVal')
@@ -484,6 +492,13 @@ class DCRInterface(Secp256k1Interface):
def getNewAddress(self, use_segwit: bool = True, label: str = 'swap_receive') -> str:
return self.rpc_wallet('getnewaddress')
def getWalletTransaction(self, txid: bytes):
try:
return bytes.fromhex(self.rpc_wallet('gettransaction', [txid.hex()])['hex'])
except Exception as ex:
# TODO: filter errors
return None
def getProofOfFunds(self, amount_for, extra_commit_bytes):
# TODO: Lock unspent and use same output/s to fund bid
@@ -1299,7 +1314,7 @@ class DCRInterface(Secp256k1Interface):
return bytes.fromhex(self.publishTx(b_lock_tx))
def getBLockSpendTxFee(self, tx, fee_rate: int) -> int:
witness_bytes = 120 # TODO
witness_bytes = 115
size = len(tx.serialize()) + witness_bytes
pay_fee = round(fee_rate * size / 1000)
self._log.info(f'BLockSpendTx fee_rate, vsize, fee: {fee_rate}, {size}, {pay_fee}.')