File tree 3 files changed +31
-10
lines changed
express/test/unit/lightning
3 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 1
1
import * as t from 'io-ts' ;
2
- import { LightningOnchainRequest } from '@bitgo/public-types' ;
2
+ import { LightningOnchainRecipient } from '@bitgo/public-types' ;
3
3
import { PendingApprovalData , TxRequestState } from '@bitgo/sdk-core' ;
4
+ import { BigIntFromString } from 'io-ts-types' ;
4
5
5
6
// 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
+ } ) ;
13
13
14
14
export type LightningOnchainWithdrawParams = t . TypeOf < typeof LightningOnchainWithdrawParams > ;
15
15
Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ export interface ILightningWallet {
163
163
* On chain withdrawal
164
164
* @param {LightningOnchainWithdrawParams } params - Withdraw parameters
165
165
* @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
167
167
* @returns {Promise<LightningOnchainWithdrawResponse> } Withdraw result containing transaction request details and status
168
168
*/
169
169
withdrawOnchain ( params : LightningOnchainWithdrawParams ) : Promise < LightningOnchainWithdrawResponse > ;
Original file line number Diff line number Diff line change @@ -82,7 +82,28 @@ describe('Lightning Withdraw Routes', () => {
82
82
should ( firstArg ) . have . property ( 'satsPerVbyte' , BigInt ( inputParams . satsPerVbyte ) ) ;
83
83
} ) ;
84
84
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 ( ) => {
86
107
const inputParams = {
87
108
satsPerVbyte : '15' ,
88
109
} ;
You can’t perform that action at this time.
0 commit comments