mirror of
https://github.com/basicswap/basicswap.git
synced 2026-06-08 04:01:41 +02:00
fix: match Part address type used for funded itx and createSCLockTx
This commit is contained in:
@@ -6482,7 +6482,7 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
xmr_swap.a_lock_tx = pi.promoteMockTx(
|
||||
ci_from, prefunded_tx, xmr_swap.a_lock_tx_script
|
||||
)
|
||||
self.log.info("Using pre-funded tx")
|
||||
self.log.info(f"Using pre-funded {ci_from.ticker()} tx")
|
||||
else:
|
||||
xmr_swap.a_lock_tx = ci_from.createSCLockTx(
|
||||
bid.amount, xmr_swap.a_lock_tx_script, xmr_swap.vkbv
|
||||
|
||||
@@ -139,13 +139,17 @@ class AtomicSwapInterface(ProtocolInterface):
|
||||
swap_type = SwapTypes.SELLER_FIRST
|
||||
|
||||
def getFundedInitiateTxTemplate(
|
||||
self, ci, amount: int, sub_fee: bool, feerate: int = None
|
||||
self,
|
||||
ci,
|
||||
amount: int,
|
||||
sub_fee: bool,
|
||||
feerate: int = None,
|
||||
lock_unspents: bool = False,
|
||||
) -> bytes:
|
||||
addr_to = self.getMockScriptAddr(ci)
|
||||
funded_tx = ci.createRawFundedTransaction(
|
||||
addr_to, amount, sub_fee, lock_unspents=False, feerate=feerate
|
||||
addr_to, amount, sub_fee, lock_unspents=lock_unspents, feerate=feerate
|
||||
)
|
||||
|
||||
return bytes.fromhex(funded_tx)
|
||||
|
||||
def promoteMockTx(self, ci, mock_tx: bytes, script: bytearray) -> bytearray:
|
||||
|
||||
@@ -221,8 +221,37 @@ class XmrSwapInterface(ProtocolInterface):
|
||||
|
||||
return CScript([2, Kal, Kaf, 2, CScriptOp(OP_CHECKMULTISIG)])
|
||||
|
||||
def getMockScriptAddr(self, ci):
|
||||
script = self.getMockScript()
|
||||
if ci.coin_type() == Coins.PART:
|
||||
# Use btc-segwit address to match createSCLockTx()
|
||||
# _use_segwit is false for Particl
|
||||
return ci.encode_p2wsh(ci.getScriptDest(script))
|
||||
return (
|
||||
ci.encodeScriptDest(ci.getScriptDest(script))
|
||||
if ci._use_segwit
|
||||
else ci.encode_p2sh(script)
|
||||
)
|
||||
|
||||
def getMockScriptScriptPubkey(self, ci) -> bytearray:
|
||||
script = self.getMockScript()
|
||||
if ci.coin_type() == Coins.PART:
|
||||
# Use btc-segwit address to match createSCLockTx()
|
||||
# _use_segwit is false for Particl
|
||||
return ci.getScriptDest(script)
|
||||
return (
|
||||
ci.getScriptDest(script)
|
||||
if ci._use_segwit
|
||||
else ci.get_p2sh_script_pubkey(script)
|
||||
)
|
||||
|
||||
def getFundedInitiateTxTemplate(
|
||||
self, ci, amount: int, sub_fee: bool, feerate: int = None
|
||||
self,
|
||||
ci,
|
||||
amount: int,
|
||||
sub_fee: bool,
|
||||
feerate: int = None,
|
||||
lock_unspents: bool = False,
|
||||
) -> bytes:
|
||||
if ci.coin_type() == Coins.BCH:
|
||||
# Workaround, BCH getScriptDest() uses OP_HASH256
|
||||
@@ -231,7 +260,7 @@ class XmrSwapInterface(ProtocolInterface):
|
||||
else:
|
||||
addr_to = self.getMockScriptAddr(ci)
|
||||
funded_tx = ci.createRawFundedTransaction(
|
||||
addr_to, amount, sub_fee, lock_unspents=False, feerate=feerate
|
||||
addr_to, amount, sub_fee, lock_unspents=lock_unspents, feerate=feerate
|
||||
)
|
||||
return bytes.fromhex(funded_tx)
|
||||
|
||||
@@ -275,7 +304,7 @@ class XmrSwapInterface(ProtocolInterface):
|
||||
raise ValueError("Too many mocked outputs found")
|
||||
ctx.nLockTime = 0
|
||||
|
||||
return ctx.serialize_without_witness()
|
||||
return ctx.serialize()
|
||||
|
||||
def getMockPubkey(self, ci) -> bytes:
|
||||
return ci.getPubkey(self._mock_key)
|
||||
@@ -308,4 +337,4 @@ class XmrSwapInterface(ProtocolInterface):
|
||||
raise ValueError("swap output not found")
|
||||
tx_obj.vout[lock_vout].scriptPubKey = ci.getPkDest(Kbs)
|
||||
|
||||
return tx_obj.serialize_without_witness()
|
||||
return tx_obj.serialize()
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
- Added warning text for fee above 1.2 x local estimate.
|
||||
- Added subfee bid option.
|
||||
- Increase DCR fee estimate by 1 byte.
|
||||
- Waits for the refund and refund spend txn locks to expire before trying to submit them.
|
||||
|
||||
|
||||
0.14.5
|
||||
|
||||
@@ -104,7 +104,7 @@ class Test(BaseTest):
|
||||
)
|
||||
|
||||
def test_010_txn_size(self):
|
||||
logging.info("---------- Test {} txn_size".format(self.test_coin_from.name))
|
||||
logging.info(f"---------- Test {self.test_coin_from.name} txn_size")
|
||||
|
||||
self.ensure_balance(self.test_coin_from, 0, 100.0)
|
||||
|
||||
@@ -159,7 +159,7 @@ class Test(BaseTest):
|
||||
|
||||
ci.rpc_wallet("sendrawtransaction", [lock_tx.hex()])
|
||||
rv = ci.rpc_wallet("gettransaction", [txid])
|
||||
wallet_tx_fee = -ci.make_int(rv["details"][0]["fee"])
|
||||
wallet_tx_fee = -ci.make_int(rv["fee"])
|
||||
|
||||
assert wallet_tx_fee >= expect_fee_int
|
||||
assert wallet_tx_fee - expect_fee_int < 20
|
||||
|
||||
@@ -2595,7 +2595,7 @@ class Test(BaseTest):
|
||||
swap_clients[2],
|
||||
bid_id,
|
||||
BidStates.SWAP_COMPLETED,
|
||||
wait_for=120,
|
||||
wait_for=180,
|
||||
)
|
||||
wait_for_bid(
|
||||
test_delay_event,
|
||||
@@ -2603,7 +2603,7 @@ class Test(BaseTest):
|
||||
bid_id,
|
||||
BidStates.SWAP_COMPLETED,
|
||||
sent=True,
|
||||
wait_for=120,
|
||||
wait_for=180,
|
||||
)
|
||||
|
||||
# Verify expected inputs were used
|
||||
|
||||
Reference in New Issue
Block a user