From ecc0db9d8fe5b7206b5738e08504525832099a5a Mon Sep 17 00:00:00 2001 From: Parv Tiwari Date: Mon, 13 Oct 2025 17:24:10 +0530 Subject: [PATCH 1/2] feat: lightning on chain intent change non compulsory sats per vbyte, numBlocks added if satsPerVbyte not present we are going to estimate it TICKET: BTC-2638 --- .../src/wallet/lightning.ts | 4 +- .../lightning/lightningWithdrawRoutes.test.ts | 40 ++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/modules/abstract-lightning/src/wallet/lightning.ts b/modules/abstract-lightning/src/wallet/lightning.ts index 0ce42b7fc4..a0c0a28c8c 100644 --- a/modules/abstract-lightning/src/wallet/lightning.ts +++ b/modules/abstract-lightning/src/wallet/lightning.ts @@ -165,7 +165,8 @@ export interface ILightningWallet { * On chain withdrawal * @param {LightningOnchainWithdrawParams} params - Withdraw parameters * @param {LightningOnchainRecipient[]} params.recipients - The recipients to pay - * @param {bigint} params.satsPerVbyte - Value for sats per virtual byte + * @param {bigint} [params.satsPerVbyte] - Optional value for sats per virtual byte. If not present, it will be estimated. + * @param {number} [params.numBlocks] - Target blocks for the transaction to be confirmed * @param {string} params.passphrase - The wallet passphrase * @param {string} [params.sequenceId] - Optional sequence ID for the respective withdraw transfer * @param {string} [params.comment] - Optional comment for the respective withdraw transfer @@ -337,6 +338,7 @@ export class LightningWallet implements ILightningWallet { onchainRequest: { recipients: params.recipients, satsPerVbyte: params.satsPerVbyte, + numBlocks: params.numBlocks, }, intentType: 'payment', }, diff --git a/modules/express/test/unit/lightning/lightningWithdrawRoutes.test.ts b/modules/express/test/unit/lightning/lightningWithdrawRoutes.test.ts index d3d95406b4..1263536b5b 100644 --- a/modules/express/test/unit/lightning/lightningWithdrawRoutes.test.ts +++ b/modules/express/test/unit/lightning/lightningWithdrawRoutes.test.ts @@ -32,6 +32,7 @@ describe('Lightning Withdraw Routes', () => { }, ], satsPerVbyte: '15', + numBlocks: 3, passphrase: 'password123', }; @@ -85,10 +86,11 @@ describe('Lightning Withdraw Routes', () => { // we decode the amountMsat string to bigint, it should be in bigint format when passed to payInvoice should(firstArg).have.property('recipients', decodedRecipients); should(firstArg).have.property('satsPerVbyte', BigInt(inputParams.satsPerVbyte)); + should(firstArg).have.property('numBlocks', inputParams.numBlocks); should(firstArg).have.property('passphrase', inputParams.passphrase); }); - it('should throw an error if the satsPerVbyte is missing in the request params', async () => { + it('should not throw an error if the satsPerVbyte and/or numBlocks is missing in the request params', async () => { const inputParams = { recipients: [ { @@ -99,15 +101,43 @@ describe('Lightning Withdraw Routes', () => { passphrase: 'password123', }; + const expectedResponse: LightningOnchainWithdrawResponse = { + txRequestState: 'delivered', + txRequestId: '123', + withdrawStatus: { + status: 'delivered', + txid: 'tx123', + }, + }; + + const onchainWithdrawStub = sinon.stub().resolves(expectedResponse); + const mockLightningWallet = { + withdrawOnchain: onchainWithdrawStub, + }; + + // Mock the module import + const proxyquire = require('proxyquire'); + const lightningWithdrawRoutes = proxyquire('../../../src/lightning/lightningWithdrawRoutes', { + '@bitgo/abstract-lightning': { + getLightningWallet: () => mockLightningWallet, + }, + }); + + const walletStub = {}; + const coinStub = { + wallets: () => ({ get: sinon.stub().resolves(walletStub) }), + }; + const stubBitgo = sinon.createStubInstance(BitGo as any, { coin: coinStub }); + const req = mockRequestObject({ params: { id: 'testWalletId', coin }, body: inputParams, + bitgo: stubBitgo, }); - req.bitgo = bitgo; - await should(handleLightningWithdraw(req)).be.rejectedWith( - 'Invalid request body for withdrawing on chain lightning balance' - ); + const result = await lightningWithdrawRoutes.handleLightningWithdraw(req); + + should(result).deepEqual(expectedResponse); }); it('should throw an error if the recipients is missing in the request params', async () => { From ca817a637015a33584fd68dbf5c36592b6a13608 Mon Sep 17 00:00:00 2001 From: Parv Tiwari Date: Tue, 14 Oct 2025 22:54:02 +0530 Subject: [PATCH 2/2] feat: bump public types TICKET: BTC-2638 --- modules/abstract-lightning/package.json | 2 +- modules/bitgo/package.json | 2 +- modules/express/encryptedPrivKeys.json | 2 +- modules/express/package.json | 2 +- modules/sdk-coin-sol/package.json | 2 +- modules/sdk-core/package.json | 2 +- yarn.lock | 8 ++++---- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/abstract-lightning/package.json b/modules/abstract-lightning/package.json index c962e8707e..e56e3b251b 100644 --- a/modules/abstract-lightning/package.json +++ b/modules/abstract-lightning/package.json @@ -39,7 +39,7 @@ ] }, "dependencies": { - "@bitgo/public-types": "5.29.0", + "@bitgo/public-types": "5.31.0", "@bitgo/sdk-core": "^36.12.0", "@bitgo/statics": "^58.4.0", "@bitgo/utxo-lib": "^11.11.0", diff --git a/modules/bitgo/package.json b/modules/bitgo/package.json index f1ffb6d4d1..86778d9d8a 100644 --- a/modules/bitgo/package.json +++ b/modules/bitgo/package.json @@ -138,7 +138,7 @@ "superagent": "^9.0.1" }, "devDependencies": { - "@bitgo/public-types": "5.29.0", + "@bitgo/public-types": "5.31.0", "@bitgo/sdk-opensslbytes": "^2.1.0", "@bitgo/sdk-test": "^9.1.4", "@openpgp/web-stream-tools": "0.0.14", diff --git a/modules/express/encryptedPrivKeys.json b/modules/express/encryptedPrivKeys.json index 431b389c97..fa9742e4d4 100644 --- a/modules/express/encryptedPrivKeys.json +++ b/modules/express/encryptedPrivKeys.json @@ -1,3 +1,3 @@ { - "61f039aad587c2000745c687373e0fa9": "{\"iv\":\"W14so0ZwIVOO/5y4cl3H3g==\",\"v\":1,\"iter\":10000,\"ks\":256,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"Jeck6aR6egU=\",\"ct\":\"GfqFuIoLp5jOTSTTB1byjWlW4D/8WBTr35P2UDjud0b0nA0WnJVAytbNkTlSIsRemhXQrcwhA74/BwZ14zvU4Frtmt3D3tvqKtb4i1ZVPREpcsIbp9V/RC+E5acNX6+bUCMXVZMEuYEGtkDxNRSIGsRZkAeTFlg=\"}" + "61f039aad587c2000745c687373e0fa9": "{\"iv\":\"/Gnh+Ip1G+IOhy+Cms+umQ==\",\"v\":1,\"iter\":10000,\"ks\":256,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"FYnd1xwReTw=\",\"ct\":\"vgnCvdJ1Z9sqeV6urYxNsscwnkB/6eSPsZhzaW4Cuc7RKEY1uWNlleR0Tjtd8nlQuhsA5UXFpOID3lHHHjPDvB+jWtRm08I2F+HNGYuklWG12vIiSrY2KnkYRJkyCghn5Pq3iEimQb9M2kkwj5wf4EtfAiz9jsY=\"}" } \ No newline at end of file diff --git a/modules/express/package.json b/modules/express/package.json index ca9b6df9cf..be029ec493 100644 --- a/modules/express/package.json +++ b/modules/express/package.json @@ -58,7 +58,7 @@ "superagent": "^9.0.1" }, "devDependencies": { - "@bitgo/public-types": "5.29.0", + "@bitgo/public-types": "5.31.0", "@bitgo/sdk-lib-mpc": "^10.8.1", "@bitgo/sdk-test": "^9.1.4", "@types/argparse": "^1.0.36", diff --git a/modules/sdk-coin-sol/package.json b/modules/sdk-coin-sol/package.json index 8a4c531655..d6afd3e5c5 100644 --- a/modules/sdk-coin-sol/package.json +++ b/modules/sdk-coin-sol/package.json @@ -40,7 +40,7 @@ ] }, "dependencies": { - "@bitgo/public-types": "5.29.0", + "@bitgo/public-types": "5.31.0", "@bitgo/sdk-core": "^36.12.0", "@bitgo/sdk-lib-mpc": "^10.8.1", "@bitgo/statics": "^58.4.0", diff --git a/modules/sdk-core/package.json b/modules/sdk-core/package.json index b6500e9d1b..ef7a5f0eb7 100644 --- a/modules/sdk-core/package.json +++ b/modules/sdk-core/package.json @@ -40,7 +40,7 @@ ] }, "dependencies": { - "@bitgo/public-types": "5.29.0", + "@bitgo/public-types": "5.31.0", "@bitgo/sdk-lib-mpc": "^10.8.1", "@bitgo/secp256k1": "^1.5.0", "@bitgo/sjcl": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index 3248be8426..d47859977b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -934,10 +934,10 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@bitgo/public-types@5.29.0": - version "5.29.0" - resolved "https://registry.npmjs.org/@bitgo/public-types/-/public-types-5.29.0.tgz#4ceae8cf837359b0cb8808f417aef64ae2f52839" - integrity sha512-E1zKNPwDmMKoJq/WC0Igg4ftdGX5DUMu49hi1vqjkdMebFliHRrPiVTSiGwDkFj7kwZbaNORNMqS/Qv4WugV0g== +"@bitgo/public-types@5.31.0": + version "5.31.0" + resolved "https://registry.npmjs.org/@bitgo/public-types/-/public-types-5.31.0.tgz#1af37545bdaaf6bb65de6a9c47cb38817d16472c" + integrity sha512-4uiFZHcwVPwfDKLG/lNPy8zIfp8esVxAjXLWrx5LUHZBKguphWWgmx6RzP2LwFr6H4GZ7pxDO3xr7AF0RRL3Ug== dependencies: fp-ts "^2.0.0" io-ts "npm:@bitgo-forks/io-ts@2.1.4"