Skip to content

Commit 16216b4

Browse files
authored
Merge pull request #7237 from BitGo/BTC-2638-non-compulsory-sats-per-vbyte
non compulsory sats per vbyte, numblocks for lightning withdraw
2 parents 4d0f4d1 + ca817a6 commit 16216b4

File tree

9 files changed

+48
-16
lines changed

9 files changed

+48
-16
lines changed

modules/abstract-lightning/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
]
4040
},
4141
"dependencies": {
42-
"@bitgo/public-types": "5.29.0",
42+
"@bitgo/public-types": "5.31.0",
4343
"@bitgo/sdk-core": "^36.12.0",
4444
"@bitgo/statics": "^58.4.0",
4545
"@bitgo/utxo-lib": "^11.11.0",

modules/abstract-lightning/src/wallet/lightning.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ export interface ILightningWallet {
165165
* On chain withdrawal
166166
* @param {LightningOnchainWithdrawParams} params - Withdraw parameters
167167
* @param {LightningOnchainRecipient[]} params.recipients - The recipients to pay
168-
* @param {bigint} params.satsPerVbyte - Value for sats per virtual byte
168+
* @param {bigint} [params.satsPerVbyte] - Optional value for sats per virtual byte. If not present, it will be estimated.
169+
* @param {number} [params.numBlocks] - Target blocks for the transaction to be confirmed
169170
* @param {string} params.passphrase - The wallet passphrase
170171
* @param {string} [params.sequenceId] - Optional sequence ID for the respective withdraw transfer
171172
* @param {string} [params.comment] - Optional comment for the respective withdraw transfer
@@ -337,6 +338,7 @@ export class LightningWallet implements ILightningWallet {
337338
onchainRequest: {
338339
recipients: params.recipients,
339340
satsPerVbyte: params.satsPerVbyte,
341+
numBlocks: params.numBlocks,
340342
},
341343
intentType: 'payment',
342344
},

modules/bitgo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
"superagent": "^9.0.1"
139139
},
140140
"devDependencies": {
141-
"@bitgo/public-types": "5.29.0",
141+
"@bitgo/public-types": "5.31.0",
142142
"@bitgo/sdk-opensslbytes": "^2.1.0",
143143
"@bitgo/sdk-test": "^9.1.4",
144144
"@openpgp/web-stream-tools": "0.0.14",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"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=\"}"
2+
"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=\"}"
33
}

modules/express/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"superagent": "^9.0.1"
5959
},
6060
"devDependencies": {
61-
"@bitgo/public-types": "5.29.0",
61+
"@bitgo/public-types": "5.31.0",
6262
"@bitgo/sdk-lib-mpc": "^10.8.1",
6363
"@bitgo/sdk-test": "^9.1.4",
6464
"@types/argparse": "^1.0.36",

modules/express/test/unit/lightning/lightningWithdrawRoutes.test.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe('Lightning Withdraw Routes', () => {
3232
},
3333
],
3434
satsPerVbyte: '15',
35+
numBlocks: 3,
3536
passphrase: 'password123',
3637
};
3738

@@ -85,10 +86,11 @@ describe('Lightning Withdraw Routes', () => {
8586
// we decode the amountMsat string to bigint, it should be in bigint format when passed to payInvoice
8687
should(firstArg).have.property('recipients', decodedRecipients);
8788
should(firstArg).have.property('satsPerVbyte', BigInt(inputParams.satsPerVbyte));
89+
should(firstArg).have.property('numBlocks', inputParams.numBlocks);
8890
should(firstArg).have.property('passphrase', inputParams.passphrase);
8991
});
9092

91-
it('should throw an error if the satsPerVbyte is missing in the request params', async () => {
93+
it('should not throw an error if the satsPerVbyte and/or numBlocks is missing in the request params', async () => {
9294
const inputParams = {
9395
recipients: [
9496
{
@@ -99,15 +101,43 @@ describe('Lightning Withdraw Routes', () => {
99101
passphrase: 'password123',
100102
};
101103

104+
const expectedResponse: LightningOnchainWithdrawResponse = {
105+
txRequestState: 'delivered',
106+
txRequestId: '123',
107+
withdrawStatus: {
108+
status: 'delivered',
109+
txid: 'tx123',
110+
},
111+
};
112+
113+
const onchainWithdrawStub = sinon.stub().resolves(expectedResponse);
114+
const mockLightningWallet = {
115+
withdrawOnchain: onchainWithdrawStub,
116+
};
117+
118+
// Mock the module import
119+
const proxyquire = require('proxyquire');
120+
const lightningWithdrawRoutes = proxyquire('../../../src/lightning/lightningWithdrawRoutes', {
121+
'@bitgo/abstract-lightning': {
122+
getLightningWallet: () => mockLightningWallet,
123+
},
124+
});
125+
126+
const walletStub = {};
127+
const coinStub = {
128+
wallets: () => ({ get: sinon.stub().resolves(walletStub) }),
129+
};
130+
const stubBitgo = sinon.createStubInstance(BitGo as any, { coin: coinStub });
131+
102132
const req = mockRequestObject({
103133
params: { id: 'testWalletId', coin },
104134
body: inputParams,
135+
bitgo: stubBitgo,
105136
});
106-
req.bitgo = bitgo;
107137

108-
await should(handleLightningWithdraw(req)).be.rejectedWith(
109-
'Invalid request body for withdrawing on chain lightning balance'
110-
);
138+
const result = await lightningWithdrawRoutes.handleLightningWithdraw(req);
139+
140+
should(result).deepEqual(expectedResponse);
111141
});
112142

113143
it('should throw an error if the recipients is missing in the request params', async () => {

modules/sdk-coin-sol/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
]
4141
},
4242
"dependencies": {
43-
"@bitgo/public-types": "5.29.0",
43+
"@bitgo/public-types": "5.31.0",
4444
"@bitgo/sdk-core": "^36.12.0",
4545
"@bitgo/sdk-lib-mpc": "^10.8.1",
4646
"@bitgo/statics": "^58.4.0",

modules/sdk-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
]
4141
},
4242
"dependencies": {
43-
"@bitgo/public-types": "5.29.0",
43+
"@bitgo/public-types": "5.31.0",
4444
"@bitgo/sdk-lib-mpc": "^10.8.1",
4545
"@bitgo/secp256k1": "^1.5.0",
4646
"@bitgo/sjcl": "^1.0.1",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,10 +934,10 @@
934934
"@scure/base" "1.1.5"
935935
micro-eth-signer "0.7.2"
936936

937-
"@bitgo/public-types@5.29.0":
938-
version "5.29.0"
939-
resolved "https://registry.npmjs.org/@bitgo/public-types/-/public-types-5.29.0.tgz#4ceae8cf837359b0cb8808f417aef64ae2f52839"
940-
integrity sha512-E1zKNPwDmMKoJq/WC0Igg4ftdGX5DUMu49hi1vqjkdMebFliHRrPiVTSiGwDkFj7kwZbaNORNMqS/Qv4WugV0g==
937+
"@bitgo/public-types@5.31.0":
938+
version "5.31.0"
939+
resolved "https://registry.npmjs.org/@bitgo/public-types/-/public-types-5.31.0.tgz#1af37545bdaaf6bb65de6a9c47cb38817d16472c"
940+
integrity sha512-4uiFZHcwVPwfDKLG/lNPy8zIfp8esVxAjXLWrx5LUHZBKguphWWgmx6RzP2LwFr6H4GZ7pxDO3xr7AF0RRL3Ug==
941941
dependencies:
942942
fp-ts "^2.0.0"
943943
io-ts "npm:@bitgo-forks/[email protected]"

0 commit comments

Comments
 (0)