@@ -46,6 +46,7 @@ class LightningService {
4646 trustedPeersNoReserve: Env . trustedLnPeers. map ( \. nodeId) ,
4747 perChannelReserveSats: 1
4848 )
49+ config. includeUntrustedPendingInSpendable = true
4950
5051 let builder = Builder . fromConfig ( config: config)
5152
@@ -69,8 +70,6 @@ class LightningService {
6970 // Configure gossip source from current settings
7071 configureGossipSource ( builder: builder, rgsServerUrl: rgsServerUrl)
7172
72- builder. setEntropyBip39Mnemonic ( mnemonic: mnemonic, passphrase: passphrase)
73-
7473 Logger . debug ( " Building node... " )
7574 let storeId = try await VssStoreIdProvider . shared. getVssStoreId ( walletIndex: walletIndex)
7675
@@ -79,16 +78,21 @@ class LightningService {
7978 Logger . debug ( " Building ldk-node with vssUrl: ' \( vssUrl) ' " )
8079 Logger . debug ( " Building ldk-node with lnurlAuthServerUrl: ' \( lnurlAuthServerUrl) ' " )
8180
81+ // Create NodeEntropy from mnemonic
82+ let nodeEntropy = NodeEntropy . fromBip39Mnemonic ( mnemonic: mnemonic, passphrase: passphrase)
83+
8284 try await ServiceQueue . background ( . ldk) {
8385 if !lnurlAuthServerUrl. isEmpty {
8486 self . node = try builder. buildWithVssStore (
87+ nodeEntropy: nodeEntropy,
8588 vssUrl: vssUrl,
8689 storeId: storeId,
8790 lnurlAuthServerUrl: lnurlAuthServerUrl,
8891 fixedHeaders: [ : ]
8992 )
9093 } else {
9194 self . node = try builder. buildWithVssStoreAndFixedHeaders (
95+ nodeEntropy: nodeEntropy,
9296 vssUrl: vssUrl,
9397 storeId: storeId,
9498 fixedHeaders: [ : ]
@@ -411,7 +415,7 @@ class LightningService {
411415 }
412416 }
413417
414- func send( bolt11: String , sats: UInt64 ? = nil , params: SendingParameters ? = nil ) async throws -> PaymentHash {
418+ func send( bolt11: String , sats: UInt64 ? = nil , params: RouteParametersConfig ? = nil ) async throws -> PaymentHash {
415419 guard let node else {
416420 throw AppError ( serviceError: . nodeNotSetup)
417421 }
@@ -432,10 +436,10 @@ class LightningService {
432436 return try await ServiceQueue . background ( . ldk) {
433437 if let sats {
434438 try node. bolt11Payment ( ) . sendUsingAmount (
435- invoice: . fromStr( invoiceStr: bolt11) , amountMsat: sats * 1000 , sendingParameters : params
439+ invoice: . fromStr( invoiceStr: bolt11) , amountMsat: sats * 1000 , routeParameters : params
436440 )
437441 } else {
438- try node. bolt11Payment ( ) . send ( invoice: . fromStr( invoiceStr: bolt11) , sendingParameters : params)
442+ try node. bolt11Payment ( ) . send ( invoice: . fromStr( invoiceStr: bolt11) , routeParameters : params)
439443 }
440444 }
441445 } catch {
@@ -717,9 +721,9 @@ extension LightningService {
717721 " ⏳ Channel pending: channelId: \( channelId) userChannelId: \( userChannelId) formerTemporaryChannelId: \( formerTemporaryChannelId) counterpartyNodeId: \( counterpartyNodeId) fundingTxo: \( fundingTxo) "
718722 )
719723 await refreshChannelCache ( )
720- case let . channelReady( channelId, userChannelId, counterpartyNodeId) :
724+ case let . channelReady( channelId, userChannelId, counterpartyNodeId, fundingTxo ) :
721725 Logger . info (
722- " 👐 Channel ready: channelId: \( channelId) userChannelId: \( userChannelId) counterpartyNodeId: \( counterpartyNodeId ?? " ? " ) "
726+ " 👐 Channel ready: channelId: \( channelId) userChannelId: \( userChannelId) counterpartyNodeId: \( counterpartyNodeId ?? " ? " ) fundingTxo: \( fundingTxo != nil ? " \( fundingTxo! . txid ) : \( fundingTxo! . vout ) " : " nil " ) "
723727 )
724728 await refreshChannelCache ( )
725729 case let . channelClosed( channelId, userChannelId, counterpartyNodeId, reason) :
@@ -815,6 +819,20 @@ extension LightningService {
815819 case let . balanceChanged( oldSpendableOnchain, newSpendableOnchain, oldTotalOnchain, newTotalOnchain, oldLightning, newLightning) :
816820 Logger
817821 . info ( " 💰 Balance changed: onchain= \( oldSpendableOnchain) -> \( newSpendableOnchain) lightning= \( oldLightning) -> \( newLightning) " )
822+
823+ // MARK: Splice Events
824+
825+ case let . splicePending( channelId, userChannelId, counterpartyNodeId, newFundingTxo) :
826+ Logger
827+ . info (
828+ " 🔀 Splice pending: channelId= \( channelId) userChannelId= \( userChannelId) counterpartyNodeId= \( counterpartyNodeId) newFundingTxo= \( newFundingTxo) "
829+ )
830+ await refreshChannelCache ( )
831+ case let . spliceFailed( channelId, userChannelId, counterpartyNodeId, abandonedFundingTxo) :
832+ Logger
833+ . warn (
834+ " ❌ Splice failed: channelId= \( channelId) userChannelId= \( userChannelId) counterpartyNodeId= \( counterpartyNodeId) abandonedFundingTxo= \( abandonedFundingTxo != nil ? " \( abandonedFundingTxo!. txid) : \( abandonedFundingTxo!. vout) " : " nil " ) "
835+ )
818836 }
819837 }
820838 }
0 commit comments