From 04f0c38810b249805f44c092c30e4a13ea24dafe Mon Sep 17 00:00:00 2001 From: michael1011 Date: Fri, 18 Oct 2024 22:06:21 +0200 Subject: [PATCH] feat: implement Discount CT Enabled on regtest and testnet --- e2e/chainSwaps/chainSwaps.spec.ts | 2 +- package-lock.json | 95 ++++++++++++++++++++++--------- package.json | 4 +- regtest | 2 +- src/components/Fees.tsx | 8 ++- src/utils/compat.ts | 23 ++++---- tests/components/Fees.spec.tsx | 4 +- 7 files changed, 92 insertions(+), 46 deletions(-) diff --git a/e2e/chainSwaps/chainSwaps.spec.ts b/e2e/chainSwaps/chainSwaps.spec.ts index 3911da4f..d49ee342 100644 --- a/e2e/chainSwaps/chainSwaps.spec.ts +++ b/e2e/chainSwaps/chainSwaps.spec.ts @@ -28,7 +28,7 @@ test.describe("Chain swap", () => { await inputReceiveAmount.fill(receiveAmount); const inputSendAmount = page.locator("input[data-testid='sendAmount']"); - const sendAmount = "0.0100168"; + const sendAmount = "0.01001551"; await expect(inputSendAmount).toHaveValue(sendAmount); const inputOnchainAddress = page.locator( diff --git a/package-lock.json b/package-lock.json index 508c3445..9a40e8e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,13 +20,13 @@ "bitcoinjs-lib": "^6.1.6", "bolt11": "^1.4.1", "boltz-bolt12": "^0.1.2", - "boltz-core": "^2.1.2", + "boltz-core": "^2.1.3", "buffer": "^6.0.3", "create-hmac": "^1.1.7", "ecpair": "^2.1.0", "ethers": "^6.13.2", "iframe-resizer": "^5.2.4", - "liquidjs-lib": "^6.0.2-liquid.35", + "liquidjs-lib": "^6.0.2-liquid.36", "localforage": "^1.10.0", "loglevel": "^1.9.1", "qr-scanner": "^1.4.2", @@ -3797,9 +3797,10 @@ } }, "node_modules/@openzeppelin/contracts": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-5.0.2.tgz", - "integrity": "sha512-ytPc6eLGcHHnapAZ9S+5qsdomhjo6QBHTDRRBFfTxXIpsicMhVPouPgmUPebZZZGX7vt9USA+Z+0M0dSVtSUEA==" + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-5.1.0.tgz", + "integrity": "sha512-p1ULhl7BXzjjbha5aqst+QMLY+4/LCWADXOCsmLHRM77AqiPjnd9vvUN9sosUfhL9JGKpZ0TjEGxgvnizmWGSA==", + "license": "MIT" }, "node_modules/@playwright/test": { "version": "1.46.0", @@ -4853,6 +4854,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/randombytes/-/randombytes-2.0.3.tgz", "integrity": "sha512-+NRgihTfuURllWCiIAhm1wsJqzsocnqXM77V/CalsdJIYSRGEHMnritxh+6EsBklshC+clo1KgnN14qgSGeQdw==", + "license": "MIT", "dependencies": { "@types/node": "*" } @@ -5416,6 +5418,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/bip174-liquid/-/bip174-liquid-1.0.3.tgz", "integrity": "sha512-e69sC0Cq2tBJuhG2+wieXv40DN13YBR/wbIjZp4Mqwpar5vQm8Ldqijdd6N33XG7LtfvQi/zKm5fSzdPY/9mgw==", + "license": "MIT", "engines": { "node": ">=8.0.0" } @@ -5443,12 +5446,10 @@ } }, "node_modules/bip66": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", - "integrity": "sha512-nemMHz95EmS38a26XbbdxIYj5csHd3RMP3H5bwQknX0WYHF01qhpufP42mLOwVICuH2JmhIhXiWs89MfUGL7Xw==", - "dependencies": { - "safe-buffer": "^5.0.1" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-2.0.0.tgz", + "integrity": "sha512-kBG+hSpgvZBrkIm9dt5T1Hd/7xGCPEX2npoxAWZfsK1FvjgaxySEh2WizjyIstWXriKo9K9uJ4u0OnsyLDUPXQ==", + "license": "MIT" }, "node_modules/bitcoinjs-lib": { "version": "6.1.6", @@ -5490,17 +5491,23 @@ } }, "node_modules/bitset": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/bitset/-/bitset-5.1.1.tgz", - "integrity": "sha512-oKaRp6mzXedJ1Npo86PKhWfDelI6HxxJo+it9nAcBB0HLVvYVp+5i6yj6DT5hfFgo+TS5T57MRWtw8zhwdTs3g==", + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/bitset/-/bitset-5.2.3.tgz", + "integrity": "sha512-uZ7++Z60MC9cZ+7YzQ1v9yPDydcjhmcMjGx2yoGTjjSXBoVMmTr2LCRbkpI19S9P/C75hhP7Bsakj+gVzVUDbQ==", + "license": "MIT", "engines": { "node": "*" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/rawify" } }, "node_modules/blech32": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/blech32/-/blech32-1.1.2.tgz", "integrity": "sha512-C5qxzoF9KyX88X8Zz18cZ6BOeL0n5/Eg/cDot1frntkArRMwg1djNim5wA6QFWwu0lJ1LN8iiRMN4Lp2kZzdfA==", + "license": "MIT", "dependencies": { "long": "^4.0.0" }, @@ -5511,7 +5518,8 @@ "node_modules/blech32/node_modules/long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", + "license": "Apache-2.0" }, "node_modules/bn.js": { "version": "5.2.1", @@ -5550,26 +5558,36 @@ "license": "MIT" }, "node_modules/boltz-core": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/boltz-core/-/boltz-core-2.1.2.tgz", - "integrity": "sha512-b19P5dFIWl/bf/sqBlSRbTj7+/48hWaTUfR1qVkWaPr+OR1T0gNuYP86EOi3yQwR689GxXk0adeV5rKc9ue3Xw==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/boltz-core/-/boltz-core-2.1.3.tgz", + "integrity": "sha512-ATL8T3Mk5zJ/12B/3UubcVHkHvKed3fv/FwSwL9n348dzY7dq73dEU9INTJe7LSU5O+ewb8gdeUrpUi/SYxToA==", + "license": "AGPL-3.0", "dependencies": { "@boltz/bitcoin-ops": "^2.0.0", - "@openzeppelin/contracts": "^5.0.2", + "@openzeppelin/contracts": "^5.1.0", "@vulpemventures/secp256k1-zkp": "^3.2.1", "bip32": "^4.0.0", "bip65": "^1.0.3", - "bip66": "^1.1.5", - "bitcoinjs-lib": "^6.1.5", + "bip66": "^2.0.0", + "bitcoinjs-lib": "^6.1.6", "bn.js": "^5.2.1", "ecpair": "^2.1.0", - "varuint-bitcoin": "^1.1.2" + "varuint-bitcoin": "^2.0.0" }, "engines": { - "node": ">=14" + "node": ">=18" }, "peerDependencies": { - "liquidjs-lib": "^6.0.2-liquid.34" + "liquidjs-lib": "^6.0.2-liquid.36" + } + }, + "node_modules/boltz-core/node_modules/varuint-bitcoin": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/varuint-bitcoin/-/varuint-bitcoin-2.0.0.tgz", + "integrity": "sha512-6QZbU/rHO2ZQYpWFDALCDSRsXbAs1VOEmXAxtbtjLtKuMJ/FQ8YbhfxlaiKv5nklci0M6lZtlZyxo9Q+qNnyog==", + "license": "MIT", + "dependencies": { + "uint8array-tools": "^0.0.8" } }, "node_modules/brace-expansion": { @@ -10282,9 +10300,10 @@ "dev": true }, "node_modules/liquidjs-lib": { - "version": "6.0.2-liquid.35", - "resolved": "https://registry.npmjs.org/liquidjs-lib/-/liquidjs-lib-6.0.2-liquid.35.tgz", - "integrity": "sha512-Q5ZNWu4zqtkvWShrZOBusLJcNgsr4iF8xEDor/zUG4mOabl2vw7YGvwNeQaGJ8JQA9InlzU1Q9NJi/h07HkI8Q==", + "version": "6.0.2-liquid.36", + "resolved": "https://registry.npmjs.org/liquidjs-lib/-/liquidjs-lib-6.0.2-liquid.36.tgz", + "integrity": "sha512-JvQ0FmfX2UYOJy2/pJgXmnhwDoxqksR3pk9euwmNNNByXq3t/wOEKEFkL7z7KFHCTa0gmuSqC5f2T2aN9Dhnkg==", + "license": "MIT", "dependencies": { "@types/randombytes": "^2.0.0", "bech32": "^2.0.0", @@ -10304,6 +10323,15 @@ "node": ">=8.0.0" } }, + "node_modules/liquidjs-lib/node_modules/bip66": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", + "integrity": "sha512-nemMHz95EmS38a26XbbdxIYj5csHd3RMP3H5bwQknX0WYHF01qhpufP42mLOwVICuH2JmhIhXiWs89MfUGL7Xw==", + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/localforage": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz", @@ -11701,6 +11729,7 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/slip77/-/slip77-0.2.0.tgz", "integrity": "sha512-LQaxb1Hef10kU36qvk71tlSt5BWph7GM0j+t2n5zs169X4QfnNbb6xqKZ38X3ETzGmCQaVdBwr925HDagHra/Q==", + "license": "MIT", "dependencies": { "@types/node": "^13.9.1", "create-hmac": "^1.1.7", @@ -11713,7 +11742,8 @@ "node_modules/slip77/node_modules/@types/node": { "version": "13.13.52", "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==", + "license": "MIT" }, "node_modules/solid-icons": { "version": "1.1.0", @@ -12421,6 +12451,15 @@ "node": ">=14.17" } }, + "node_modules/uint8array-tools": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/uint8array-tools/-/uint8array-tools-0.0.8.tgz", + "integrity": "sha512-xS6+s8e0Xbx++5/0L+yyexukU7pz//Yg6IHg3BKhXotg1JcYtgxVcUctQ0HxLByiJzpAkNFawz1Nz5Xadzo82g==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/undici-types": { "version": "6.18.2", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.18.2.tgz", diff --git a/package.json b/package.json index 40fb4cb5..666de3da 100644 --- a/package.json +++ b/package.json @@ -65,13 +65,13 @@ "bitcoinjs-lib": "^6.1.6", "bolt11": "^1.4.1", "boltz-bolt12": "^0.1.2", - "boltz-core": "^2.1.2", + "boltz-core": "^2.1.3", "buffer": "^6.0.3", "create-hmac": "^1.1.7", "ecpair": "^2.1.0", "ethers": "^6.13.2", "iframe-resizer": "^5.2.4", - "liquidjs-lib": "^6.0.2-liquid.35", + "liquidjs-lib": "^6.0.2-liquid.36", "localforage": "^1.10.0", "loglevel": "^1.9.1", "qr-scanner": "^1.4.2", diff --git a/regtest b/regtest index ee9ba83a..c6df76dc 160000 --- a/regtest +++ b/regtest @@ -1 +1 @@ -Subproject commit ee9ba83a88ceeed43c46eb210f6df4fb1b69d241 +Subproject commit c6df76dcfdeb8b28a2f3114166df8669f87d3657 diff --git a/src/components/Fees.tsx b/src/components/Fees.tsx index f9aac384..ac0b3c3c 100644 --- a/src/components/Fees.tsx +++ b/src/components/Fees.tsx @@ -19,6 +19,10 @@ import { formatAmount } from "../utils/denomination"; import { getPair } from "../utils/helper"; import Denomination from "./settings/Denomination"; +// When sending to an unconfidential address, we need to add an extra +// confidential OP_RETURN output with 1 sat inside +const unconfidentialExtra = 5; + const Fees = () => { const { t, pairs, fetchPairs, denomination, separator } = useGlobalContext(); @@ -68,7 +72,7 @@ const Fees = () => { reverseCfg.fees.minerFees.claim + reverseCfg.fees.minerFees.lockup; if (isToUnconfidentialLiquid()) { - fee += 1; + fee += unconfidentialExtra; } setMinerFee(fee); @@ -80,7 +84,7 @@ const Fees = () => { chainCfg.fees.minerFees.server + chainCfg.fees.minerFees.user.claim; if (isToUnconfidentialLiquid()) { - fee += 1; + fee += unconfidentialExtra; } setMinerFee(fee); diff --git a/src/utils/compat.ts b/src/utils/compat.ts index 22e144de..b37fd50d 100644 --- a/src/utils/compat.ts +++ b/src/utils/compat.ts @@ -195,16 +195,19 @@ const getConstructRefundTransaction = ( liquidNetwork?: LiquidNetwork, blindingKey?: Buffer, ) => - targetFee(feePerVbyte, (fee) => - fn( - refundDetails as any[], - outputScript, - timeoutBlockHeight, - addOneSatBuffer ? fee + 1 : fee, - isRbf, - liquidNetwork, - blindingKey, - ), + targetFee( + feePerVbyte, + (fee) => + fn( + refundDetails as any[], + outputScript, + timeoutBlockHeight, + addOneSatBuffer ? fee + 1 : fee, + isRbf, + liquidNetwork, + blindingKey, + ), + config.network !== "mainnet", ); }; diff --git a/tests/components/Fees.spec.tsx b/tests/components/Fees.spec.tsx index 0d9b407d..55d65ba5 100644 --- a/tests/components/Fees.spec.tsx +++ b/tests/components/Fees.spec.tsx @@ -90,7 +90,7 @@ describe("Fees component", () => { const fees = pairs.reverse[BTC][LBTC].fees; expect(signals.minerFee()).toEqual( - fees.minerFees.lockup + fees.minerFees.claim + 1, + fees.minerFees.lockup + fees.minerFees.claim + 5, ); }); @@ -115,7 +115,7 @@ describe("Fees component", () => { const fees = pairs.chain[BTC][LBTC].fees; expect(signals.minerFee()).toEqual( - fees.minerFees.server + fees.minerFees.user.claim + 1, + fees.minerFees.server + fees.minerFees.user.claim + 5, ); }); });