From 12b975e0dd755094414f03577f9f5da67e9de221 Mon Sep 17 00:00:00 2001 From: dev Date: Sun, 27 Aug 2023 03:18:36 +0800 Subject: [PATCH] electrum:firo: Changes for review --- client/asset/firo/firo.go | 20 +++++++++++++------ dex/testing/firo/README_ELECTRUM_HARNESSES.md | 5 +++-- dex/testing/firo/electrum.sh | 2 +- dex/testing/firo/electrum_regtest_wallet_info | 10 ---------- 4 files changed, 18 insertions(+), 19 deletions(-) delete mode 100644 dex/testing/firo/electrum_regtest_wallet_info diff --git a/client/asset/firo/firo.go b/client/asset/firo/firo.go index 04f22e1cf8..18edd3d433 100644 --- a/client/asset/firo/firo.go +++ b/client/asset/firo/firo.go @@ -7,6 +7,7 @@ import ( "context" "encoding/json" "errors" + "flag" "fmt" "io" "math" @@ -31,7 +32,6 @@ const ( minNetworkVersion = 141201 // bitcoin 0.14 base walletTypeRPC = "firodRPC" walletTypeElectrum = "electrumRPC" - walletTypeLegacy = "" estimateFeeConfs = 2 // 2 blocks should be enough mainnetExplorerFeeAPI = "https://explorer.firo.org/insight-api-zcoin/utils/estimatefee" @@ -119,6 +119,15 @@ func (d *Driver) Info() *asset.WalletInfo { // canceled. The configPath can be an empty string, in which case the standard // system location of the firod config file is assumed. func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network) (asset.Wallet, error) { + if flag.Lookup("test.v") != nil { + // If testing we need to do a workaround check for legacy no-type wallet. + // This Only happens calling from regnet_test.go when the btc livetest code + // calls NewWallet. Maybe bch client had a similar problem. + if cfg.Type == "" { + cfg.Type = walletTypeRPC + } + } + var params *chaincfg.Params switch network { case dex.Mainnet: @@ -152,7 +161,7 @@ func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network) Segwit: false, InitTxSize: dexbtc.InitTxSize, InitTxSizeBase: dexbtc.InitTxSizeBase, - LegacyBalance: false, // set true only for walletTypeRPC below + LegacyBalance: cfg.Type == walletTypeRPC, LegacyRawFeeLimit: true, // sendrawtransaction Has single arg allowhighfees ArglessChangeAddrRPC: true, // getrawchangeaddress has No address-type arg OmitAddressType: true, // getnewaddress has No address-type arg @@ -161,7 +170,7 @@ func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network) NumericGetRawRPC: false, // getrawtransaction uses either 0/1 Or true/false LegacyValidateAddressRPC: true, // use validateaddress to read 'ismine' bool SingularWallet: true, // one wallet/node - UnlockSpends: true, // does Not unlock coins after sendrawtransaction + UnlockSpends: true, // Firo chain wallet does Not unlock coins after sendrawtransaction AssetID: BipID, FeeEstimator: estimateFee, ExternalFeeEstimator: fetchExternalFee, @@ -169,10 +178,9 @@ func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network) } switch cfg.Type { - case walletTypeRPC, walletTypeLegacy: - cloneCFG.LegacyBalance = true + case walletTypeRPC: var exw *btc.ExchangeWalletFullNode - // override PrivKeyFunc - we Do need our own Firo dumpprivkey fn + // override PrivKeyFunc - we need our own Firo dumpprivkey fn cloneCFG.PrivKeyFunc = func(addr string) (*btcec.PrivateKey, error) { return privKeyForAddress(exw, addr) } diff --git a/dex/testing/firo/README_ELECTRUM_HARNESSES.md b/dex/testing/firo/README_ELECTRUM_HARNESSES.md index e01183f21c..6eb005f63d 100644 --- a/dex/testing/firo/README_ELECTRUM_HARNESSES.md +++ b/dex/testing/firo/README_ELECTRUM_HARNESSES.md @@ -38,7 +38,8 @@ The **electrum.sh** script depends on [python3], [python3 pip] and [git] to run. Python3 v3.6 is coded but this script was tested using python3.10. Some testing (minimal) was done with 3.7. Python 3.8, 3.9 would be expected to work although untested. However using Python 3.11 there are dependencies which will not build -and are unsupported by their respective maintainers on PyPI. Git should be latest.Pip will be re-downloaded and it's version upgraded by the script into a virtual environment each time. +and are unsupported by their respective maintainers on PyPI. Git should be latest. +Pip will be re-downloaded and it's version upgraded by the script into a virtual environment each time. ### Architecture @@ -102,7 +103,7 @@ from files in `contrib/requirements` directory into the sandbox. If any need bui this point. A prepared, empty but encrypted electrum wallet is copied to the electrum data -directory at **~/dextest/electrum/firo/client/wallet/regtest/wallets** directory. +directory at **~/dextest/electrum/firo/client/wallet/regtest/wallets**. By default the electrum client is started as a daemon and the default wallet is loaded. Use **stop-daemon** script to stop the daemon. diff --git a/dex/testing/firo/electrum.sh b/dex/testing/firo/electrum.sh index aaa4f03a71..9724c410b8 100755 --- a/dex/testing/firo/electrum.sh +++ b/dex/testing/firo/electrum.sh @@ -119,4 +119,4 @@ else ./electrum-firo ${ELECTRUM_REGTEST_ARGS} list_wallets ./electrum-firo ${ELECTRUM_REGTEST_ARGS} getinfo echo "use 'stop_daemon.sh' to stop the daemon" -fi \ No newline at end of file +fi diff --git a/dex/testing/firo/electrum_regtest_wallet_info b/dex/testing/firo/electrum_regtest_wallet_info deleted file mode 100644 index 09134c8101..0000000000 --- a/dex/testing/firo/electrum_regtest_wallet_info +++ /dev/null @@ -1,10 +0,0 @@ -Electrum-Firo wallet with `regtest` chain params ------------------------------------------------- - -The wallet is empty of funds as a new blockchain is always created with `regtest` - -Send some funds from the harness and mine them - -PASS: -'abc' -