diff --git a/docker/regtest/dockerfile-deps/joinmarket/directory_node/Dockerfile b/docker/regtest/dockerfile-deps/joinmarket/directory_node/Dockerfile index 2ca9a4a39..22b13bfb2 100644 --- a/docker/regtest/dockerfile-deps/joinmarket/directory_node/Dockerfile +++ b/docker/regtest/dockerfile-deps/joinmarket/directory_node/Dockerfile @@ -1,9 +1,9 @@ -FROM debian:bullseye-20220801-slim +FROM python:3.11-slim-bookworm RUN apt-get update \ && apt-get install -qq --no-install-recommends gnupg tini procps vim git iproute2 supervisor \ # joinmarket dependencies - curl build-essential automake pkg-config libtool python3-dev python3-venv python3-pip python3-setuptools libltdl-dev \ + curl build-essential automake pkg-config libtool libltdl-dev \ tor \ && rm -rf /var/lib/apt/lists/* @@ -14,7 +14,7 @@ ENV REPO_REF master WORKDIR /src RUN git clone "$REPO" . --depth=10 --branch "$REPO_BRANCH" && git checkout "$REPO_REF" -RUN ./install.sh --docker-install --disable-secp-check --without-qt +RUN ./install.sh --docker-install --disable-os-deps-check --disable-secp-check --without-qt ENV DATADIR /root/.joinmarket ENV CONFIG ${DATADIR}/joinmarket.cfg diff --git a/docker/regtest/dockerfile-deps/joinmarket/latest/Dockerfile b/docker/regtest/dockerfile-deps/joinmarket/latest/Dockerfile index f875f186a..871c28759 100644 --- a/docker/regtest/dockerfile-deps/joinmarket/latest/Dockerfile +++ b/docker/regtest/dockerfile-deps/joinmarket/latest/Dockerfile @@ -1,9 +1,9 @@ -FROM debian:bullseye-20220801-slim +FROM python:3.11-slim-bookworm RUN apt-get update \ && apt-get install -qq --no-install-recommends gnupg tini procps vim git iproute2 supervisor \ # joinmarket dependencies - curl build-essential automake pkg-config libtool python3-dev python3-venv python3-pip python3-setuptools libltdl-dev \ + curl build-essential automake pkg-config libtool libltdl-dev \ tor \ && rm -rf /var/lib/apt/lists/* @@ -14,7 +14,7 @@ ENV REPO_REF master WORKDIR /src RUN git clone "$REPO" . --depth=10 --branch "$REPO_BRANCH" && git checkout "$REPO_REF" -RUN ./install.sh --docker-install --disable-secp-check --without-qt +RUN ./install.sh --docker-install --disable-os-deps-check --disable-secp-check --without-qt ENV DATADIR /root/.joinmarket ENV CONFIG ${DATADIR}/joinmarket.cfg diff --git a/package-lock.json b/package-lock.json index 0b7be2acf..4c8c1031e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "@testing-library/user-event": "^13.5.0", "@types/jest": "^29.0.3", "@types/node": "^17.0.35", + "@types/qrcode": "^1.5.2", "@types/react": "^17.0.43", "@types/react-dom": "^17.0.14", "conventional-changelog": "^3.1.25", @@ -4710,6 +4711,15 @@ "integrity": "sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ==", "dev": true }, + "node_modules/@types/qrcode": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.2.tgz", + "integrity": "sha512-W4KDz75m7rJjFbyCctzCtRzZUj+PrUHV+YjqDp50sSRezTbrtEAIq2iTzC6lISARl3qw+8IlcCyljdcVJE0Wug==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/qs": { "version": "6.9.7", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", @@ -25662,6 +25672,15 @@ "integrity": "sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ==", "dev": true }, + "@types/qrcode": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.2.tgz", + "integrity": "sha512-W4KDz75m7rJjFbyCctzCtRzZUj+PrUHV+YjqDp50sSRezTbrtEAIq2iTzC6lISARl3qw+8IlcCyljdcVJE0Wug==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/qs": { "version": "6.9.7", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", diff --git a/package.json b/package.json index 570a6678e..44d813d27 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@testing-library/user-event": "^13.5.0", "@types/jest": "^29.0.3", "@types/node": "^17.0.35", + "@types/qrcode": "^1.5.2", "@types/react": "^17.0.43", "@types/react-dom": "^17.0.14", "conventional-changelog": "^3.1.25", diff --git a/src/components/App.tsx b/src/components/App.tsx index 310ad0328..f3d39934c 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -53,9 +53,9 @@ export default function App() { const isReloadingWalletInfo = useMemo(() => reloadingWalletInfoCounter > 0, [reloadingWalletInfoCounter]) const startWallet = useCallback( - (name: Api.WalletName, auth: Api.ApiAuthContext) => { - setSession({ name, auth }) - setCurrentWallet({ name, token: auth.token }) + (walletFileName: Api.WalletFileName, auth: Api.ApiAuthContext) => { + setSession({ walletFileName, auth }) + setCurrentWallet({ walletFileName, token: auth.token }) }, [setCurrentWallet], ) diff --git a/src/components/BitcoinQR.jsx b/src/components/BitcoinQR.jsx deleted file mode 100644 index 4d082d257..000000000 --- a/src/components/BitcoinQR.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import { useEffect, useState } from 'react' -import QRCode from 'qrcode' - -import { satsToBtc } from '../utils' - -export const BitcoinQR = ({ address, sats, errorCorrectionLevel = 'H', width = 260 }) => { - const [data, setData] = useState(null) - const [image, setImage] = useState(null) - - useEffect(() => { - const btc = satsToBtc(parseInt(sats, 10)) || 0 - const uri = `bitcoin:${address}${btc > 0 ? `?amount=${btc.toFixed(8)}` : ''}` - - QRCode.toDataURL(uri, { - errorCorrectionLevel, - width, - }) - .then((val) => { - setImage(val) - setData(uri) - }) - .catch(() => { - setImage(null) - setData(uri) - }) - }, [address, sats, errorCorrectionLevel, width]) - - return ( -
- {data} -
- ) -} diff --git a/src/components/BitcoinQR.tsx b/src/components/BitcoinQR.tsx new file mode 100644 index 000000000..a033b4636 --- /dev/null +++ b/src/components/BitcoinQR.tsx @@ -0,0 +1,41 @@ +import { useEffect, useState } from 'react' +import QRCode from 'qrcode' + +import { satsToBtc } from '../utils' +import { AmountSats, BitcoinAddress } from '../libs/JmWalletApi' + +interface BitcoinQRProps { + address: BitcoinAddress + amount?: AmountSats + errorCorrectionLevel?: QRCode.QRCodeErrorCorrectionLevel + width?: number +} + +export const BitcoinQR = ({ address, amount, errorCorrectionLevel = 'H', width = 260 }: BitcoinQRProps) => { + const [data, setData] = useState() + const [image, setImage] = useState() + + useEffect(() => { + const btc = amount ? satsToBtc(String(amount)) || 0 : 0 + const uri = `bitcoin:${address}${btc > 0 ? `?amount=${btc.toFixed(8)}` : ''}` + + QRCode.toDataURL(uri, { + errorCorrectionLevel, + width, + }) + .then((val) => { + setImage(val) + setData(uri) + }) + .catch(() => { + setImage(undefined) + setData(uri) + }) + }, [address, amount, errorCorrectionLevel, width]) + + return ( +
+ {data} +
+ ) +} diff --git a/src/components/CopyButton.tsx b/src/components/CopyButton.tsx index 713afc26d..c3a479338 100644 --- a/src/components/CopyButton.tsx +++ b/src/components/CopyButton.tsx @@ -38,15 +38,25 @@ interface CopyableProps { onSuccess?: () => void onError?: (e: Error) => void className?: string + disabled?: boolean } -function Copyable({ value, onSuccess, onError, className, children, ...props }: PropsWithChildren) { +function Copyable({ + value, + onSuccess, + onError, + className, + children, + disabled, + ...props +}: PropsWithChildren) { const valueFallbackInputRef = useRef(null) return ( <>