mirror of
https://github.com/basicswap/basicswap.git
synced 2026-01-28 11:25:10 +01:00
Merge pull request #251 from tecnovert/wallet_name
Add wallet_name option to basicswap.json.
This commit is contained in:
@@ -266,7 +266,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
self._rpcport = coin_settings["rpcport"]
|
||||
self._rpcauth = coin_settings["rpcauth"]
|
||||
self.rpc = make_rpc_func(self._rpcport, self._rpcauth, host=self._rpc_host)
|
||||
self._rpc_wallet = "wallet.dat"
|
||||
self._rpc_wallet = coin_settings.get("wallet_name", "wallet.dat")
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host, wallet=self._rpc_wallet
|
||||
)
|
||||
@@ -301,16 +301,14 @@ class BTCInterface(Secp256k1Interface):
|
||||
|
||||
# Wallet name is "" for some LTC and PART installs on older cores
|
||||
if self._rpc_wallet not in wallets and len(wallets) > 0:
|
||||
self._log.debug("Changing {} wallet name.".format(self.ticker()))
|
||||
self._log.debug(f"Changing {self.ticker()} wallet name.")
|
||||
for wallet_name in wallets:
|
||||
# Skip over other expected wallets
|
||||
if wallet_name in ("mweb",):
|
||||
continue
|
||||
self._rpc_wallet = wallet_name
|
||||
self._log.info(
|
||||
"Switched {} wallet name to {}.".format(
|
||||
self.ticker(), self._rpc_wallet
|
||||
)
|
||||
f"Switched {self.ticker()} wallet name to {self._rpc_wallet}."
|
||||
)
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport,
|
||||
@@ -381,9 +379,9 @@ class BTCInterface(Secp256k1Interface):
|
||||
|
||||
chain_synced = round(blockchaininfo["verificationprogress"], 3)
|
||||
if chain_synced < 1.0:
|
||||
raise ValueError("{} chain isn't synced.".format(self.coin_name()))
|
||||
raise ValueError(f"{self.coin_name()} chain isn't synced.")
|
||||
|
||||
self._log.debug("Finding block at time: {}".format(start_time))
|
||||
self._log.debug(f"Finding block at time: {start_time}")
|
||||
|
||||
rpc_conn = self.open_rpc()
|
||||
try:
|
||||
@@ -397,7 +395,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
block_hash = block_header["previousblockhash"]
|
||||
finally:
|
||||
self.close_rpc(rpc_conn)
|
||||
raise ValueError("{} wallet restore height not found.".format(self.coin_name()))
|
||||
raise ValueError(f"{self.coin_name()} wallet restore height not found.")
|
||||
|
||||
def getWalletSeedID(self) -> str:
|
||||
wi = self.rpc_wallet("getwalletinfo")
|
||||
@@ -1806,16 +1804,20 @@ class BTCInterface(Secp256k1Interface):
|
||||
def unlockWallet(self, password: str):
|
||||
if password == "":
|
||||
return
|
||||
self._log.info("unlockWallet - {}".format(self.ticker()))
|
||||
self._log.info(f"unlockWallet - {self.ticker()}")
|
||||
|
||||
if self.coin_type() == Coins.BTC:
|
||||
# Recreate wallet if none found
|
||||
# Required when encrypting an existing btc wallet, workaround is to delete the btc wallet and recreate
|
||||
wallets = self.rpc("listwallets")
|
||||
if len(wallets) < 1:
|
||||
self._log.info("Creating wallet.dat for {}.".format(self.coin_name()))
|
||||
self._log.info(
|
||||
f'Creating wallet "{self._rpc_wallet}" for {self.coin_name()}.'
|
||||
)
|
||||
# wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors
|
||||
self.rpc("createwallet", ["wallet.dat", False, True, "", False, False])
|
||||
self.rpc(
|
||||
"createwallet", [self._rpc_wallet, False, True, "", False, False]
|
||||
)
|
||||
self.rpc_wallet("encryptwallet", [password])
|
||||
|
||||
# Max timeout value, ~3 years
|
||||
@@ -1823,7 +1825,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
self._sc.checkWalletSeed(self.coin_type())
|
||||
|
||||
def lockWallet(self):
|
||||
self._log.info("lockWallet - {}".format(self.ticker()))
|
||||
self._log.info(f"lockWallet - {self.ticker()}")
|
||||
self.rpc_wallet("walletlock")
|
||||
|
||||
def get_p2sh_script_pubkey(self, script: bytearray) -> bytearray:
|
||||
|
||||
@@ -277,6 +277,9 @@ class DCRInterface(Secp256k1Interface):
|
||||
self._connection_type = coin_settings["connection_type"]
|
||||
self._altruistic = coin_settings.get("altruistic", True)
|
||||
|
||||
if "wallet_name" in coin_settings:
|
||||
raise ValueError(f"Invalid setting for {self.coin_name()}: wallet_name")
|
||||
|
||||
def open_rpc(self):
|
||||
return openrpc(self._rpcport, self._rpcauth, host=self._rpc_host)
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ class FIROInterface(BTCInterface):
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host
|
||||
)
|
||||
|
||||
if "wallet_name" in coin_settings:
|
||||
raise ValueError(f"Invalid setting for {self.coin_name()}: wallet_name")
|
||||
|
||||
def getExchangeName(self, exchange_name: str) -> str:
|
||||
return "zcoin"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class LTCInterface(BTCInterface):
|
||||
|
||||
def __init__(self, coin_settings, network, swap_client=None):
|
||||
super(LTCInterface, self).__init__(coin_settings, network, swap_client)
|
||||
self._rpc_wallet_mweb = "mweb"
|
||||
self._rpc_wallet_mweb = coin_settings.get("mweb_wallet_name", "mweb")
|
||||
self.rpc_wallet_mweb = make_rpc_func(
|
||||
self._rpcport,
|
||||
self._rpcauth,
|
||||
@@ -94,7 +94,7 @@ class LTCInterfaceMWEB(LTCInterface):
|
||||
|
||||
def __init__(self, coin_settings, network, swap_client=None):
|
||||
super(LTCInterfaceMWEB, self).__init__(coin_settings, network, swap_client)
|
||||
self._rpc_wallet = "mweb"
|
||||
self._rpc_wallet = coin_settings.get("mweb_wallet_name", "mweb")
|
||||
self.rpc_wallet = make_rpc_func(
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host, wallet=self._rpc_wallet
|
||||
)
|
||||
@@ -128,7 +128,7 @@ class LTCInterfaceMWEB(LTCInterface):
|
||||
|
||||
self._log.info("init_wallet - {}".format(self.ticker()))
|
||||
|
||||
self._log.info("Creating mweb wallet for {}.".format(self.coin_name()))
|
||||
self._log.info(f"Creating wallet {self._rpc_wallet} for {self.coin_name()}.")
|
||||
# wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors, load_on_startup
|
||||
self.rpc("createwallet", ["mweb", False, True, password, False, False, True])
|
||||
|
||||
|
||||
@@ -81,6 +81,9 @@ class NAVInterface(BTCInterface):
|
||||
self._rpcport, self._rpcauth, host=self._rpc_host
|
||||
)
|
||||
|
||||
if "wallet_name" in coin_settings:
|
||||
raise ValueError(f"Invalid setting for {self.coin_name()}: wallet_name")
|
||||
|
||||
def use_p2shp2wsh(self) -> bool:
|
||||
# p2sh-p2wsh
|
||||
return True
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2024 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2020-2024 tecnovert
|
||||
# Copyright (c) 2024 The Basicswap developers
|
||||
# Copyright (c) 2024-2025 The Basicswap developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -99,6 +99,7 @@ class XMRInterface(CoinInterface):
|
||||
self._log = self._sc.log if self._sc and self._sc.log else logging
|
||||
self._wallet_password = None
|
||||
self._have_checked_seed = False
|
||||
self._wallet_filename = coin_settings.get("wallet_name", "swap_wallet")
|
||||
|
||||
daemon_login = None
|
||||
if coin_settings.get("rpcuser", "") != "":
|
||||
@@ -175,9 +176,6 @@ class XMRInterface(CoinInterface):
|
||||
ensure(new_priority >= 0 and new_priority < 4, "Invalid fee_priority value")
|
||||
self._fee_priority = new_priority
|
||||
|
||||
def setWalletFilename(self, wallet_filename):
|
||||
self._wallet_filename = wallet_filename
|
||||
|
||||
def createWallet(self, params):
|
||||
if self._wallet_password is not None:
|
||||
params["password"] = self._wallet_password
|
||||
|
||||
Reference in New Issue
Block a user