Fix addcoin decred.

master^2
tecnovert 7 months ago
parent 5f6819afcb
commit ebdbe115dd
  1. 11
      basicswap/basicswap.py
  2. 8
      bin/basicswap_prepare.py
  3. 16
      docker/production/compose-fragments/1_decred-wallet.yml
  4. 16
      docker/production/compose-fragments/8_decred-daemon.yml
  5. 25
      docker/production/decred_daemon/Dockerfile
  6. 11
      docker/production/decred_daemon/entrypoint.sh
  7. 19
      docker/production/decred_wallet/Dockerfile
  8. 11
      docker/production/decred_wallet/entrypoint.sh
  9. 18
      docker/production/example.env
  10. 11
      docker/production/notes.md
  11. 9
      docker/production/scripts/build_yml_files.py

@ -1071,8 +1071,6 @@ class BasicSwap(BaseApp):
key_str = 'main_wallet_seedid_alt_' + db_key_coin_name
self.setStringKV(key_str, legacy_root_hash.hex(), session)
session.commit() # else get error database is locked!?
# Clear any saved addresses
self.clearStringKV('receive_addr_' + db_key_coin_name, session)
self.clearStringKV('stealth_addr_' + db_key_coin_name, session)
@ -1140,12 +1138,13 @@ class BasicSwap(BaseApp):
if session is None:
self.closeSession(use_session, commit=False)
def clearStringKV(self, str_key: str, str_val: str) -> None:
def clearStringKV(self, str_key: str, session=None) -> None:
try:
session = self.openSession()
session.execute('DELETE FROM kv_string WHERE key = :key', {'key': str_key})
use_session = self.openSession(session)
use_session.execute('DELETE FROM kv_string WHERE key = :key', {'key': str_key})
finally:
self.closeSession(session)
if session is None:
self.closeSession(use_session)
def getPreFundedTx(self, linked_type: int, linked_id: bytes, tx_type: int, session=None) -> Optional[bytes]:
try:

@ -1295,7 +1295,7 @@ def initialise_wallets(particl_wallet_mnemonic, with_coins, data_dir, settings,
if not swap_client.use_tor_proxy:
# Cannot set -bind or -whitebind together with -listen=0
daemon_args.append('-nolisten')
coins_to_create_wallets_for = (Coins.PART, Coins.BTC, Coins.LTC, Coins.DASH)
coins_to_create_wallets_for = (Coins.PART, Coins.BTC, Coins.LTC, Coins.DCR, Coins.DASH)
# Always start Particl, it must be running to initialise a wallet in addcoin mode
# Particl must be loaded first as subsequent coins are initialised from the Particl mnemonic
start_daemons = ['particl', ] + [c for c in with_coins if c != 'particl']
@ -1322,8 +1322,10 @@ def initialise_wallets(particl_wallet_mnemonic, with_coins, data_dir, settings,
swap_client.setCoinRunParams(c)
swap_client.createCoinInterface(c)
if c in coins_to_create_wallets_for:
if c == Coins.DCR:
if coin_settings['manage_wallet_daemon']:
if coin_settings['manage_wallet_daemon'] is False:
continue
from basicswap.interface.dcr.util import createDCRWallet
dcr_password = coin_settings['wallet_pwd'] if WALLET_ENCRYPTION_PWD == '' else WALLET_ENCRYPTION_PWD
@ -1335,7 +1337,7 @@ def initialise_wallets(particl_wallet_mnemonic, with_coins, data_dir, settings,
args = [os.path.join(coin_settings['bindir'], filename), '--create'] + extra_opts
hex_seed = swap_client.getWalletKey(Coins.DCR, 1).hex()
createDCRWallet(args, hex_seed, logger, threading.Event())
if c in coins_to_create_wallets_for:
continue
swap_client.waitForDaemonRPC(c, with_wallet=False)
# Create wallet if it doesn't exist yet
wallets = swap_client.callcoinrpc(c, 'listwallets')

@ -0,0 +1,16 @@
monero_wallet:
image: i_decred_wallet
build:
context: decred_wallet
dockerfile: Dockerfile
container_name: decred_wallet
volumes:
- ${DATA_PATH}/decred_wallet:/data
expose:
- ${DCR_WALLET_RPC_PORT}
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped

@ -0,0 +1,16 @@
monero_daemon:
image: i_decred_daemon
build:
context: decred_daemon
dockerfile: Dockerfile
container_name: decred_daemon
volumes:
- ${DATA_PATH}/decred_daemon:/data
expose:
- ${DCR_RPC_PORT}
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped

@ -0,0 +1,25 @@
FROM i_swapclient as install_stage
RUN basicswap-prepare --preparebinonly --bindir=/coin_bin --withcoin=decred --withoutcoins=particl && \
find /coin_bin -name *.tar.gz -delete
FROM debian:bullseye-slim
COPY --from=install_stage /coin_bin .
ENV DCR_DATA /data
RUN groupadd -r decred && useradd -r -m -g decred decred \
&& apt-get update \
&& apt-get install -qq --no-install-recommends gosu \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir "$DCR_DATA" \
&& chown -R decred:decred "$DCR_DATA" \
&& ln -sfn "$DECRED_DATA" /home/decred/decred \
&& chown -h decred:decred /home/decred/decred
VOLUME /data
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 9108 9109
CMD ["/decred/dcrd", "--datadir=/data"]

@ -0,0 +1,11 @@
#!/bin/bash
set -e
if [[ "$1" == "dcrctl" || "$1" == "dcrd" || "$1" == "dcrwallet" ]]; then
mkdir -p "$DECRED_DATA"
chown -h decred:decred /home/decred/decred
exec gosu decred "$@"
else
exec "$@"
fi

@ -0,0 +1,19 @@
FROM i_decred_daemon
ENV DCR_DATA /data
RUN groupadd -r decred && useradd -r -m -g decred decred \
&& apt-get update \
&& apt-get install -qq --no-install-recommends gosu \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir "$DCR_DATA" \
&& chown -R decred:decred "$DCR_DATA" \
&& ln -sfn "$DECRED_DATA" /home/decred/decred \
&& chown -h decred:decred /home/decred/decred
VOLUME /data
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 9209
CMD ["/decred/dcrwallet", "--datadir=/data"]

@ -0,0 +1,11 @@
#!/bin/bash
set -e
if [[ "$1" == "dcrctl" || "$1" == "dcrd" || "$1" == "dcrwallet" ]]; then
mkdir -p "$DECRED_DATA"
chown -h decred:decred /home/decred/decred
exec gosu decred "$@"
else
exec "$@"
fi

@ -14,17 +14,25 @@ PART_ZMQ_PORT=20792
PART_RPC_USER=particl_user
PART_RPC_PWD=particl_pwd
BTC_DATA_DIR=/data/bitcoin
BTC_RPC_HOST=bitcoin_core
BTC_RPC_PORT=19796
BTC_RPC_USER=bitcoin_user
BTC_RPC_PWD=bitcoin_pwd
LTC_DATA_DIR=/data/litecoin
LTC_RPC_HOST=litecoin_core
LTC_RPC_PORT=19795
LTC_RPC_USER=litecoin_user
LTC_RPC_PWD=litecoin_pwd
BTC_DATA_DIR=/data/bitcoin
BTC_RPC_HOST=bitcoin_core
BTC_RPC_PORT=19796
BTC_RPC_USER=bitcoin_user
BTC_RPC_PWD=bitcoin_pwd
DCR_DATA_DIR=/data/decred
DCR_RPC_HOST=decred_daemon
DCR_RPC_PORT=DCR_RPC_PORT
DCR_WALLET_RPC_HOST=decred_wallet
DCR_WALLET_RPC_PORT=9209
DCR_RPC_USER=decred_user
DCR_RPC_PWD=decred_pass
XMR_DATA_DIR=/data/monero_daemon
XMR_RPC_HOST=monero_daemon

@ -3,6 +3,13 @@
This will setup Basicswap so that each coin runs in it's own container.
### Coin notes
- Decred is only partially supported, the wallet will need to be initialised manually.
## Setup
Install dependencies:
sudo apt install basez docker-compose
@ -33,13 +40,14 @@ Create docker-compose config:
# Using the helper script:
./scripts/build_yml_files.py -c bitcoin monero
# Or
# Or manually:
cat compose-fragments/0_start.yml > docker-compose.yml
# Add the relevant coin fragments
cat compose-fragments/1_bitcoin.yml >> docker-compose.yml
cat compose-fragments/1_litecoin.yml >> docker-compose.yml
cat compose-fragments/1_decred-wallet.yml >> docker-compose.yml
cat compose-fragments/1_monero-wallet.yml >> docker-compose.yml
cat compose-fragments/1_pivx.yml >> docker-compose.yml
cat compose-fragments/1_dash.yml >> docker-compose.yml
@ -121,6 +129,7 @@ Start BasicSwap:
popd
docker-compose build monero_daemon
docker-compose build decred_daemon
docker-compose build
docker-compose build --no-cache swapclient

@ -66,6 +66,15 @@ def main():
for line in fp_in:
fp.write(line)
continue
if coin_name == 'decred':
with open(os.path.join(fragments_dir, '1_decred-wallet.yml'), 'rb') as fp_in:
for line in fp_in:
fp.write(line)
fpp.write(line)
with open(os.path.join(fragments_dir, '8_decred-daemon.yml'), 'rb') as fp_in:
for line in fp_in:
fp.write(line)
continue
with open(os.path.join(fragments_dir, f'1_{coin_name}.yml'), 'rb') as fp_in:
for line in fp_in:
fp.write(line)

Loading…
Cancel
Save