Skip to content

Commit

Permalink
dex/testing: Start regtest electrum as daemon by default
Browse files Browse the repository at this point in the history
  • Loading branch information
xorzero777 committed Jul 22, 2023
1 parent 9d7918b commit 7a8fd9e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion client/asset/firo/firo.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network)
Segwit: false,
InitTxSize: dexbtc.InitTxSize,
InitTxSizeBase: dexbtc.InitTxSizeBase,
LegacyBalance: true,
LegacyBalance: false, // set true only for walletTypeRPC below
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 @@ -171,6 +171,7 @@ func NewWallet(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network)

switch cfg.Type {
case walletTypeRPC, walletTypeLegacy:
cloneCFG.LegacyBalance = true
var exw *btc.ExchangeWalletFullNode
// override PrivKeyFunc - we Do need our own Firo dumpprivkey fn
cloneCFG.PrivKeyFunc = func(addr string) (*btcec.PrivateKey, error) {
Expand Down
3 changes: 3 additions & 0 deletions dex/testing/firo/README_ELECTRUM_HARNESSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ 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.

By default the electrum client is started as a daemon and the default wallet is loaded.
Use **stop-daemon** script to stop the daemon.

The electrum client wallet will connect to the firo electrumX daemon.

### Simnet Trade Testing
Expand Down
23 changes: 21 additions & 2 deletions dex/testing/firo/electrum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ REPO_DIR=${ELECTRUM_DIR}/electrum-repo
WALLET_DIR=${ELECTRUM_DIR}/wallet
NET_DIR=${WALLET_DIR}/regtest

# startup options (Default start as a daemon)
# Uncomment this line to start with gui
#START_WITH_GUI="1"
ELECTRUM_REGTEST_ARGS="--regtest --dir=${WALLET_DIR}"
WALLET_PASSWORD="abc"

rm -rf ${NET_DIR}/blockchain_headers ${NET_DIR}/forks ${NET_DIR}/certs ${NET_DIR}/wallets/default_wallet
mkdir -p ${NET_DIR}/regtest
mkdir -p ${NET_DIR}/wallets
Expand All @@ -59,7 +65,11 @@ source ${ELECTRUM_DIR}/venv/bin/activate
python --version
python -m pip install --upgrade pip # can support more versions than ensurepip
pip install -e .
pip install requests cryptography pycryptodomex pyqt5
pip install requests cryptography pycryptodomex
if [ -n "$START_WITH_GUI" ];
then
pip install pyqt5
fi

cp "${SCRIPT_DIR}/electrum_regtest_wallet" "${NET_DIR}/wallets/default_wallet"

Expand Down Expand Up @@ -100,4 +110,13 @@ rpcpassword=pass
rpcbind=127.0.0.1:${RPCPORT}
EOF

./electrum-firo --regtest --dir=${WALLET_DIR}
if [ -n "$START_WITH_GUI" ];
then
./electrum-firo ${ELECTRUM_REGTEST_ARGS}
else
./electrum-firo ${ELECTRUM_REGTEST_ARGS} daemon --detach
./electrum-firo ${ELECTRUM_REGTEST_ARGS} load_wallet --password=${WALLET_PASSWORD}
./electrum-firo ${ELECTRUM_REGTEST_ARGS} list_wallets
./electrum-firo ${ELECTRUM_REGTEST_ARGS} getinfo
echo "use 'stop_daemon.sh' to stop the daemon"
fi
5 changes: 5 additions & 0 deletions dex/testing/firo/stop-daemon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

curl --data-binary \
'{"jsonrpc":"2.0","id":"curltext","method":"stop","params":[]}' \
http://user:[email protected]:8001

0 comments on commit 7a8fd9e

Please sign in to comment.