Skip to content

Commit

Permalink
electrum:firo: Changes for review
Browse files Browse the repository at this point in the history
  • Loading branch information
xorzero777 committed Aug 26, 2023
1 parent 4cc0e9a commit 12b975e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
20 changes: 14 additions & 6 deletions client/asset/firo/firo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"math"
Expand All @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -161,18 +170,17 @@ 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,
PrivKeyFunc: nil, // set only for walletTypeRPC below
}

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)
}
Expand Down
5 changes: 3 additions & 2 deletions dex/testing/firo/README_ELECTRUM_HARNESSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion dex/testing/firo/electrum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
fi
10 changes: 0 additions & 10 deletions dex/testing/firo/electrum_regtest_wallet_info

This file was deleted.

0 comments on commit 12b975e

Please sign in to comment.