File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1151,6 +1151,23 @@ export const waitForLdk = async (): Promise<void> => {
11511151 } ) ;
11521152} ;
11531153
1154+ export const waitForLdkChannels = async ( ) : Promise < void > => {
1155+ await tryNTimes ( {
1156+ toTry : async ( ) => {
1157+ const channelsResult = await ldk . listUsableChannels ( ) ;
1158+ if ( channelsResult . isOk ( ) ) {
1159+ if ( channelsResult . value . length > 0 ) {
1160+ return ok ( channelsResult . value ) ;
1161+ }
1162+ return err ( 'no channels ready' ) ;
1163+ }
1164+ return err ( 'error getting channels' ) ;
1165+ } ,
1166+ times : 5 ,
1167+ interval : 1000 ,
1168+ } ) ;
1169+ } ;
1170+
11541171/**
11551172 * Returns the current LDK node id.
11561173 * @returns {Promise<Result<string>> }
@@ -1579,6 +1596,8 @@ export const payLightningInvoice = async ({
15791596 amount ?: number ;
15801597} ) : Promise < Result < string > > => {
15811598 try {
1599+ await waitForLdkChannels ( ) ;
1600+
15821601 const addPeersResponse = await addPeers ( ) ;
15831602 if ( addPeersResponse . isErr ( ) ) {
15841603 return err ( addPeersResponse . error . message ) ;
You can’t perform that action at this time.
0 commit comments