mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 10:28:10 +01:00
prepare: Set changetype=bech32 in BTC and LTC .conf files.
Rewrite .conf files to add changetype at startup if possible. Add combine_non_segwit_prevouts function to coin interface. Add option to list non-segwit UTXOs and combine_non_segwit_prevouts to gui. Add test for changetype and combine_non_segwit_prevouts.
This commit is contained in:
@@ -102,6 +102,9 @@ def prepareDataDir(
|
||||
|
||||
if base_p2p_port == BTC_BASE_PORT:
|
||||
fp.write("deprecatedrpc=create_bdb\n")
|
||||
fp.write("changetype=bech32\n")
|
||||
elif base_p2p_port == LTC_BASE_PORT:
|
||||
fp.write("changetype=bech32\n")
|
||||
elif base_p2p_port == BASE_PORT: # Particl
|
||||
fp.write("zmqpubsmsg=tcp://127.0.0.1:{}\n".format(BASE_ZMQ_PORT + node_id))
|
||||
# minstakeinterval=5 # Using walletsettings stakelimit instead
|
||||
|
||||
@@ -1808,6 +1808,41 @@ class BasicSwapTest(TestFunctions):
|
||||
ci.setActiveWallet("wallet.dat")
|
||||
chain_client_settings["manage_daemon"] = False
|
||||
|
||||
def test_015_changetype(self):
|
||||
logging.info(f"---------- Test {self.test_coin_from.name} changetype")
|
||||
ci = self.swap_clients[0].ci(self.test_coin_from)
|
||||
|
||||
addr_p2sh = ci.rpc_wallet(
|
||||
"getnewaddress", ["test_015_changetype", "p2sh-segwit"]
|
||||
)
|
||||
txid = ci.rpc_wallet("sendtoaddress", [addr_p2sh, 1])
|
||||
|
||||
tx_hex = ci.rpc_wallet("gettransaction", [txid])["hex"]
|
||||
tx = ci.rpc_wallet("decoderawtransaction", [tx_hex])
|
||||
change_vout: int = -1
|
||||
for vout in tx["vout"]:
|
||||
if "address" in vout["scriptPubKey"]:
|
||||
if vout["scriptPubKey"]["address"] == addr_p2sh:
|
||||
continue
|
||||
else:
|
||||
if addr_p2sh in vout["scriptPubKey"]["addresses"]:
|
||||
continue
|
||||
change_vout = vout["n"]
|
||||
assert vout["scriptPubKey"]["type"] == "witness_v0_keyhash"
|
||||
assert change_vout > -1
|
||||
ci.rpc_wallet("sendtoaddress", [addr_p2sh, 2])
|
||||
ci.rpc_wallet("sendtoaddress", [addr_p2sh, 3])
|
||||
|
||||
txid = ci.combine_non_segwit_prevouts()
|
||||
tx_hex = ci.rpc_wallet("gettransaction", [txid])["hex"]
|
||||
tx = ci.rpc_wallet("decoderawtransaction", [tx_hex])
|
||||
|
||||
assert len(tx["vin"]) == 3
|
||||
for vin in tx["vin"]:
|
||||
assert len(vin["scriptSig"]["hex"]) > 0
|
||||
for vout in tx["vout"]:
|
||||
assert vout["scriptPubKey"]["type"] == "witness_v0_keyhash"
|
||||
|
||||
def test_01_0_lock_bad_prevouts(self):
|
||||
logging.info(
|
||||
"---------- Test {} lock_bad_prevouts".format(self.test_coin_from.name)
|
||||
|
||||
Reference in New Issue
Block a user