File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
packages/core/src/services Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @fedimint/core ' : patch
3+ ---
4+
5+ Added select_available_gateay rpc and use it for payments instead of list_gateways
Original file line number Diff line number Diff line change @@ -77,10 +77,21 @@ export class LightningService {
7777 )
7878 }
7979
80- private async _getDefaultGatewayInfo ( ) {
80+ async getAvailableGateway ( gateway ?: LightningGateway , invoice ?: string ) {
81+ return await this . client . rpcSingle < LightningGateway | null > (
82+ 'ln' ,
83+ 'select_available_gateway' ,
84+ {
85+ maybe_gateway : gateway ?? null ,
86+ maybe_invoice : invoice ?? null ,
87+ } ,
88+ )
89+ }
90+
91+ private async _getDefaultGatewayInfo ( invoice ?: string ) {
8192 await this . updateGatewayCache ( )
82- const gateways = await this . listGateways ( )
83- return gateways [ 0 ] ?. info
93+ const gateway = await this . getAvailableGateway ( undefined , invoice )
94+ return gateway ?. info
8495 }
8596
8697 /** https://web.fedimint.org/core/FedimintWallet/LightningService/payInvoice#lightning-payinvoice-invoice-string */
@@ -89,7 +100,7 @@ export class LightningService {
89100 gatewayInfo ?: GatewayInfo ,
90101 extraMeta ?: JSONObject ,
91102 ) {
92- const gateway = gatewayInfo ?? ( await this . _getDefaultGatewayInfo ( ) )
103+ const gateway = gatewayInfo ?? ( await this . _getDefaultGatewayInfo ( invoice ) )
93104 return await this . client . rpcSingle < OutgoingLightningPayment > (
94105 'ln' ,
95106 'pay_bolt11_invoice' ,
You can’t perform that action at this time.
0 commit comments