Skip to content

Commit bd7b3d7

Browse files
authored
Merge pull request #6081 from BitGo/BTC-2072-withdraw-params-change
fix: making satsPerVbyte compulsory
2 parents 4f357bc + db457bb commit bd7b3d7

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

modules/abstract-lightning/src/codecs/api/withdraw.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import * as t from 'io-ts';
2-
import { LightningOnchainRequest } from '@bitgo/public-types';
2+
import { LightningOnchainRecipient } from '@bitgo/public-types';
33
import { PendingApprovalData, TxRequestState } from '@bitgo/sdk-core';
4+
import { BigIntFromString } from 'io-ts-types';
45

56
// todo:(current) which to keep here which to take to common types
6-
export const LightningOnchainWithdrawParams = t.intersection([
7-
LightningOnchainRequest,
8-
t.type({
9-
// todo:(current) add passphrase
10-
// passphrase: t.string,
11-
}),
12-
]);
7+
export const LightningOnchainWithdrawParams = t.type({
8+
recipients: t.array(LightningOnchainRecipient),
9+
satsPerVbyte: BigIntFromString,
10+
// todo:(current) add passphrase
11+
// passphrase: t.string,
12+
});
1313

1414
export type LightningOnchainWithdrawParams = t.TypeOf<typeof LightningOnchainWithdrawParams>;
1515

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export interface ILightningWallet {
163163
* On chain withdrawal
164164
* @param {LightningOnchainWithdrawParams} params - Withdraw parameters
165165
* @param {LightningOnchainRecipient[]} params.recipients - The recipients to pay
166-
* @param {bigint} [params.satsPerVbyte] - Optional value for sats per virtual byte
166+
* @param {bigint} params.satsPerVbyte - Value for sats per virtual byte
167167
* @returns {Promise<LightningOnchainWithdrawResponse>} Withdraw result containing transaction request details and status
168168
*/
169169
withdrawOnchain(params: LightningOnchainWithdrawParams): Promise<LightningOnchainWithdrawResponse>;

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

+22-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,28 @@ describe('Lightning Withdraw Routes', () => {
8282
should(firstArg).have.property('satsPerVbyte', BigInt(inputParams.satsPerVbyte));
8383
});
8484

85-
it('should throw an error if the passphrase is missing in the request params', async () => {
85+
it('should throw an error if the satsPerVbyte is missing in the request params', async () => {
86+
const inputParams = {
87+
recipients: [
88+
{
89+
amountSat: '500000',
90+
address: 'bcrt1qjq48cqk2u80hewdcndf539m8nnnvt845nl68x7',
91+
},
92+
],
93+
};
94+
95+
const req = mockRequestObject({
96+
params: { id: 'testWalletId', coin },
97+
body: inputParams,
98+
});
99+
req.bitgo = bitgo;
100+
101+
await should(handleLightningWithdraw(req)).be.rejectedWith(
102+
'Invalid request body for withdrawing on chain lightning balance'
103+
);
104+
});
105+
106+
it('should throw an error if the recipients is missing in the request params', async () => {
86107
const inputParams = {
87108
satsPerVbyte: '15',
88109
};

0 commit comments

Comments
 (0)