File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
integration-tests/src/services Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { TransportClient } from '../transport'
22import type {
33 CreateBolt11Response ,
44 GatewayInfo ,
5+ GetAvailableGatewayParams ,
56 JSONObject ,
67 LightningGateway ,
78 LnInternalPayState ,
@@ -77,7 +78,10 @@ export class LightningService {
7778 )
7879 }
7980
80- async getAvailableGateway ( gateway ?: LightningGateway , invoice ?: string ) {
81+ async getAvailableGateway ( {
82+ gateway,
83+ invoice,
84+ } : GetAvailableGatewayParams | undefined = { } ) {
8185 return await this . client . rpcSingle < LightningGateway | null > (
8286 'ln' ,
8387 'select_available_gateway' ,
@@ -90,7 +94,7 @@ export class LightningService {
9094
9195 private async _getDefaultGatewayInfo ( invoice ?: string ) {
9296 await this . updateGatewayCache ( )
93- const gateway = await this . getAvailableGateway ( undefined , invoice )
97+ const gateway = await this . getAvailableGateway ( { invoice } )
9498 return gateway ?. info ?? null
9599 }
96100
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ type GatewayInfo = {
1414 route_hints : RouteHint [ ]
1515 fees : FeeToAmount
1616}
17+
1718type LightningGateway = {
1819 info : GatewayInfo
1920 vetted : boolean
@@ -36,6 +37,11 @@ type OutgoingLightningPayment = {
3637
3738type PayType = { lightning : string } | { internal : string }
3839
40+ type GetAvailableGatewayParams = {
41+ gateway ?: LightningGateway
42+ invoice ?: string
43+ }
44+
3945type LnPayState =
4046 | 'created'
4147 | 'canceled'
@@ -295,4 +301,5 @@ export {
295301 WalletTransaction ,
296302 Transactions ,
297303 WalletDepositState ,
304+ GetAvailableGatewayParams ,
298305}
Original file line number Diff line number Diff line change 11import { expect } from 'vitest'
22import { keyPair } from '../test/crypto'
33import { walletTest } from '../test/fixtures'
4+ import { LightningGateway } from '@fedimint/core'
45
56walletTest (
67 'createInvoice should create a bolt11 invoice' ,
@@ -263,3 +264,19 @@ walletTest(
263264 }
264265 } ,
265266)
267+
268+ walletTest (
269+ 'getAvailableGateway should return a gateway' ,
270+ async ( { wallet } ) => {
271+ expect ( wallet ) . toBeDefined ( )
272+ expect ( wallet . isOpen ( ) ) . toBe ( true )
273+
274+ const gateway = await wallet . lightning . getAvailableGateway ( )
275+ expect ( gateway ) . toBeDefined ( )
276+ expect ( gateway ) . toMatchObject ( {
277+ info : expect . any ( Object ) ,
278+ vetted : expect . any ( Boolean ) ,
279+ ttl : expect . any ( Object ) ,
280+ } satisfies LightningGateway )
281+ } ,
282+ )
You can’t perform that action at this time.
0 commit comments