File tree Expand file tree Collapse file tree 3 files changed +31
-10
lines changed
express/test/unit/lightning Expand file tree Collapse file tree 3 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 11import * as t from 'io-ts' ;
2- import { LightningOnchainRequest } from '@bitgo/public-types' ;
2+ import { LightningOnchainRecipient } from '@bitgo/public-types' ;
33import { 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
1414export type LightningOnchainWithdrawParams = t . TypeOf < typeof LightningOnchainWithdrawParams > ;
1515
Original file line number Diff line number Diff 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 > ;
Original file line number Diff line number Diff 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 } ;
You can’t perform that action at this time.
0 commit comments