1 import { TxOut } from '../structs/TxOut.mjs';
2 import { TxIn } from '../structs/TxIn.mjs';
3 import { BigEndianScalar } from '../structs/BigEndianScalar.mjs';
4 import { WitnessProgram } from '../structs/WitnessProgram.mjs';
5 import { BlindedFailure } from '../enums/BlindedFailure.mjs';
6 import { Bolt11SemanticError } from '../enums/Bolt11SemanticError.mjs';
7 import { Bolt12SemanticError } from '../enums/Bolt12SemanticError.mjs';
8 import { COption_NoneZ } from '../enums/COption_NoneZ.mjs';
9 import { ChannelMonitorUpdateStatus } from '../enums/ChannelMonitorUpdateStatus.mjs';
10 import { ChannelShutdownState } from '../enums/ChannelShutdownState.mjs';
11 import { ConfirmationTarget } from '../enums/ConfirmationTarget.mjs';
12 import { CreationError } from '../enums/CreationError.mjs';
13 import { Currency } from '../enums/Currency.mjs';
14 import { Direction } from '../enums/Direction.mjs';
15 import { HTLCClaim } from '../enums/HTLCClaim.mjs';
16 import { IOError } from '../enums/IOError.mjs';
17 import { Level } from '../enums/Level.mjs';
18 import { Network } from '../enums/Network.mjs';
19 import { PaymentFailureReason } from '../enums/PaymentFailureReason.mjs';
20 import { Recipient } from '../enums/Recipient.mjs';
21 import { RetryableSendFailure } from '../enums/RetryableSendFailure.mjs';
22 import { Secp256k1Error } from '../enums/Secp256k1Error.mjs';
23 import { ShortChannelIdError } from '../enums/ShortChannelIdError.mjs';
24 import { SiPrefix } from '../enums/SiPrefix.mjs';
25 import { SocketAddressParseError } from '../enums/SocketAddressParseError.mjs';
26 import { UtxoLookupError } from '../enums/UtxoLookupError.mjs';
27 import { Bech32Error } from '../structs/Bech32Error.mjs';
28 import { RefundMaybeWithDerivedMetadataBuilder } from '../structs/RefundMaybeWithDerivedMetadataBuilder.mjs';
29 import { Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ } from '../structs/Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ.mjs';
30 import { Refund } from '../structs/Refund.mjs';
31 import { Result_RefundBolt12SemanticErrorZ } from '../structs/Result_RefundBolt12SemanticErrorZ.mjs';
32 import { Option_u64Z } from '../structs/Option_u64Z.mjs';
33 import { BlindedPath } from '../structs/BlindedPath.mjs';
34 import { Bolt12ParseError } from '../structs/Bolt12ParseError.mjs';
35 import { Result_RefundBolt12ParseErrorZ } from '../structs/Result_RefundBolt12ParseErrorZ.mjs';
36 import { Retry } from '../structs/Retry.mjs';
37 import { DecodeError } from '../structs/DecodeError.mjs';
38 import { Result_RetryDecodeErrorZ } from '../structs/Result_RetryDecodeErrorZ.mjs';
39 import { ShutdownScript } from '../structs/ShutdownScript.mjs';
40 import { APIError } from '../structs/APIError.mjs';
41 import { Result_NoneAPIErrorZ } from '../structs/Result_NoneAPIErrorZ.mjs';
42 import { Option_ThirtyTwoBytesZ } from '../structs/Option_ThirtyTwoBytesZ.mjs';
43 import { Option_CVec_u8ZZ } from '../structs/Option_CVec_u8ZZ.mjs';
44 import { RecipientOnionFields } from '../structs/RecipientOnionFields.mjs';
45 import { Result_RecipientOnionFieldsDecodeErrorZ } from '../structs/Result_RecipientOnionFieldsDecodeErrorZ.mjs';
46 import { TwoTuple_u64CVec_u8ZZ } from '../structs/TwoTuple_u64CVec_u8ZZ.mjs';
47 import { Result_RecipientOnionFieldsNoneZ } from '../structs/Result_RecipientOnionFieldsNoneZ.mjs';
48 import { UnsignedBolt12Invoice } from '../structs/UnsignedBolt12Invoice.mjs';
49 import { Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ } from '../structs/Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ.mjs';
50 import { Bolt12Invoice } from '../structs/Bolt12Invoice.mjs';
51 import { Result_Bolt12InvoiceBolt12SemanticErrorZ } from '../structs/Result_Bolt12InvoiceBolt12SemanticErrorZ.mjs';
52 import { Result_SchnorrSignatureNoneZ } from '../structs/Result_SchnorrSignatureNoneZ.mjs';
53 import { Option_CVec_ThirtyTwoBytesZZ } from '../structs/Option_CVec_ThirtyTwoBytesZZ.mjs';
54 import { Amount } from '../structs/Amount.mjs';
55 import { Option_AmountZ } from '../structs/Option_AmountZ.mjs';
56 import { Quantity } from '../structs/Quantity.mjs';
57 import { Option_QuantityZ } from '../structs/Option_QuantityZ.mjs';
58 import { Result_ThirtyTwoBytesNoneZ } from '../structs/Result_ThirtyTwoBytesNoneZ.mjs';
59 import { BlindedPayInfo } from '../structs/BlindedPayInfo.mjs';
60 import { Result_BlindedPayInfoDecodeErrorZ } from '../structs/Result_BlindedPayInfoDecodeErrorZ.mjs';
61 import { DelayedPaymentOutputDescriptor } from '../structs/DelayedPaymentOutputDescriptor.mjs';
62 import { Result_DelayedPaymentOutputDescriptorDecodeErrorZ } from '../structs/Result_DelayedPaymentOutputDescriptorDecodeErrorZ.mjs';
63 import { StaticPaymentOutputDescriptor } from '../structs/StaticPaymentOutputDescriptor.mjs';
64 import { Result_StaticPaymentOutputDescriptorDecodeErrorZ } from '../structs/Result_StaticPaymentOutputDescriptorDecodeErrorZ.mjs';
65 import { OutPoint } from '../structs/OutPoint.mjs';
66 import { SpendableOutputDescriptor } from '../structs/SpendableOutputDescriptor.mjs';
67 import { Result_SpendableOutputDescriptorDecodeErrorZ } from '../structs/Result_SpendableOutputDescriptorDecodeErrorZ.mjs';
68 import { Option_u32Z } from '../structs/Option_u32Z.mjs';
69 import { TwoTuple_CVec_u8Zu64Z } from '../structs/TwoTuple_CVec_u8Zu64Z.mjs';
70 import { Result_C2Tuple_CVec_u8Zu64ZNoneZ } from '../structs/Result_C2Tuple_CVec_u8Zu64ZNoneZ.mjs';
71 import { ChannelDerivationParameters } from '../structs/ChannelDerivationParameters.mjs';
72 import { Result_ChannelDerivationParametersDecodeErrorZ } from '../structs/Result_ChannelDerivationParametersDecodeErrorZ.mjs';
73 import { HTLCDescriptor } from '../structs/HTLCDescriptor.mjs';
74 import { Result_HTLCDescriptorDecodeErrorZ } from '../structs/Result_HTLCDescriptorDecodeErrorZ.mjs';
75 import { Result_NoneNoneZ } from '../structs/Result_NoneNoneZ.mjs';
76 import { Result_PublicKeyNoneZ } from '../structs/Result_PublicKeyNoneZ.mjs';
77 import { Option_BigEndianScalarZ } from '../structs/Option_BigEndianScalarZ.mjs';
78 import { Result_RecoverableSignatureNoneZ } from '../structs/Result_RecoverableSignatureNoneZ.mjs';
79 import { Result_ECDSASignatureNoneZ } from '../structs/Result_ECDSASignatureNoneZ.mjs';
80 import { Result_TransactionNoneZ } from '../structs/Result_TransactionNoneZ.mjs';
81 import { TwoTuple_ECDSASignatureCVec_ECDSASignatureZZ } from '../structs/TwoTuple_ECDSASignatureCVec_ECDSASignatureZZ.mjs';
82 import { Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ } from '../structs/Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ.mjs';
83 import { CommitmentTransaction } from '../structs/CommitmentTransaction.mjs';
84 import { HolderCommitmentTransaction } from '../structs/HolderCommitmentTransaction.mjs';
85 import { HTLCOutputInCommitment } from '../structs/HTLCOutputInCommitment.mjs';
86 import { ClosingTransaction } from '../structs/ClosingTransaction.mjs';
87 import { UnsignedChannelAnnouncement } from '../structs/UnsignedChannelAnnouncement.mjs';
88 import { ChannelPublicKeys } from '../structs/ChannelPublicKeys.mjs';
89 import { ChannelTransactionParameters } from '../structs/ChannelTransactionParameters.mjs';
90 import { ChannelSigner, ChannelSignerInterface } from '../structs/ChannelSigner.mjs';
91 import { EcdsaChannelSigner, EcdsaChannelSignerInterface } from '../structs/EcdsaChannelSigner.mjs';
92 import { WriteableEcdsaChannelSigner, WriteableEcdsaChannelSignerInterface } from '../structs/WriteableEcdsaChannelSigner.mjs';
93 import { Result_WriteableEcdsaChannelSignerDecodeErrorZ } from '../structs/Result_WriteableEcdsaChannelSignerDecodeErrorZ.mjs';
94 import { Result_CVec_u8ZNoneZ } from '../structs/Result_CVec_u8ZNoneZ.mjs';
95 import { Result_ShutdownScriptNoneZ } from '../structs/Result_ShutdownScriptNoneZ.mjs';
96 import { Option_u16Z } from '../structs/Option_u16Z.mjs';
97 import { Option_boolZ } from '../structs/Option_boolZ.mjs';
98 import { Result_WitnessNoneZ } from '../structs/Result_WitnessNoneZ.mjs';
99 import { InMemorySigner } from '../structs/InMemorySigner.mjs';
100 import { Result_InMemorySignerDecodeErrorZ } from '../structs/Result_InMemorySignerDecodeErrorZ.mjs';
101 import { ChannelDetails } from '../structs/ChannelDetails.mjs';
102 import { Route } from '../structs/Route.mjs';
103 import { LightningError } from '../structs/LightningError.mjs';
104 import { Result_RouteLightningErrorZ } from '../structs/Result_RouteLightningErrorZ.mjs';
105 import { TwoTuple_BlindedPayInfoBlindedPathZ } from '../structs/TwoTuple_BlindedPayInfoBlindedPathZ.mjs';
106 import { Result_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ } from '../structs/Result_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ.mjs';
107 import { OnionMessagePath } from '../structs/OnionMessagePath.mjs';
108 import { Result_OnionMessagePathNoneZ } from '../structs/Result_OnionMessagePathNoneZ.mjs';
109 import { Result_CVec_BlindedPathZNoneZ } from '../structs/Result_CVec_BlindedPathZNoneZ.mjs';
110 import { InFlightHtlcs } from '../structs/InFlightHtlcs.mjs';
111 import { Result_InFlightHtlcsDecodeErrorZ } from '../structs/Result_InFlightHtlcsDecodeErrorZ.mjs';
112 import { RouteHop } from '../structs/RouteHop.mjs';
113 import { Result_RouteHopDecodeErrorZ } from '../structs/Result_RouteHopDecodeErrorZ.mjs';
114 import { BlindedHop } from '../structs/BlindedHop.mjs';
115 import { BlindedTail } from '../structs/BlindedTail.mjs';
116 import { Result_BlindedTailDecodeErrorZ } from '../structs/Result_BlindedTailDecodeErrorZ.mjs';
117 import { Path } from '../structs/Path.mjs';
118 import { Result_RouteDecodeErrorZ } from '../structs/Result_RouteDecodeErrorZ.mjs';
119 import { RouteParameters } from '../structs/RouteParameters.mjs';
120 import { Result_RouteParametersDecodeErrorZ } from '../structs/Result_RouteParametersDecodeErrorZ.mjs';
121 import { PaymentParameters } from '../structs/PaymentParameters.mjs';
122 import { Result_PaymentParametersDecodeErrorZ } from '../structs/Result_PaymentParametersDecodeErrorZ.mjs';
123 import { RouteHint } from '../structs/RouteHint.mjs';
124 import { RouteHintHop } from '../structs/RouteHintHop.mjs';
125 import { Result_RouteHintDecodeErrorZ } from '../structs/Result_RouteHintDecodeErrorZ.mjs';
126 import { Result_RouteHintHopDecodeErrorZ } from '../structs/Result_RouteHintHopDecodeErrorZ.mjs';
127 import { FixedPenaltyScorer } from '../structs/FixedPenaltyScorer.mjs';
128 import { Result_FixedPenaltyScorerDecodeErrorZ } from '../structs/Result_FixedPenaltyScorerDecodeErrorZ.mjs';
129 import { NodeId } from '../structs/NodeId.mjs';
130 import { TwoTuple_u64u64Z } from '../structs/TwoTuple_u64u64Z.mjs';
131 import { Option_C2Tuple_u64u64ZZ } from '../structs/Option_C2Tuple_u64u64ZZ.mjs';
132 import { TwoTuple_Z } from '../structs/TwoTuple_Z.mjs';
133 import { TwoTuple__u1632_u1632Z } from '../structs/TwoTuple__u1632_u1632Z.mjs';
134 import { Option_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ } from '../structs/Option_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ.mjs';
135 import { Option_f64Z } from '../structs/Option_f64Z.mjs';
136 import { Record } from '../structs/Record.mjs';
137 import { Logger, LoggerInterface } from '../structs/Logger.mjs';
138 import { NetworkGraph } from '../structs/NetworkGraph.mjs';
139 import { ProbabilisticScorer } from '../structs/ProbabilisticScorer.mjs';
140 import { Result_ProbabilisticScorerDecodeErrorZ } from '../structs/Result_ProbabilisticScorerDecodeErrorZ.mjs';
141 import { BestBlock } from '../structs/BestBlock.mjs';
142 import { Result_BestBlockDecodeErrorZ } from '../structs/Result_BestBlockDecodeErrorZ.mjs';
143 import { TwoTuple_usizeTransactionZ } from '../structs/TwoTuple_usizeTransactionZ.mjs';
144 import { ThreeTuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ } from '../structs/ThreeTuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ.mjs';
145 import { Result_ChannelMonitorUpdateStatusNoneZ } from '../structs/Result_ChannelMonitorUpdateStatusNoneZ.mjs';
146 import { HTLCUpdate } from '../structs/HTLCUpdate.mjs';
147 import { UntrustedString } from '../structs/UntrustedString.mjs';
148 import { ClosureReason } from '../structs/ClosureReason.mjs';
149 import { ChannelId } from '../structs/ChannelId.mjs';
150 import { MonitorEvent } from '../structs/MonitorEvent.mjs';
151 import { FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ } from '../structs/FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ.mjs';
152 import { InitFeatures } from '../structs/InitFeatures.mjs';
153 import { Result_InitFeaturesDecodeErrorZ } from '../structs/Result_InitFeaturesDecodeErrorZ.mjs';
154 import { ChannelFeatures } from '../structs/ChannelFeatures.mjs';
155 import { Result_ChannelFeaturesDecodeErrorZ } from '../structs/Result_ChannelFeaturesDecodeErrorZ.mjs';
156 import { NodeFeatures } from '../structs/NodeFeatures.mjs';
157 import { Result_NodeFeaturesDecodeErrorZ } from '../structs/Result_NodeFeaturesDecodeErrorZ.mjs';
158 import { Bolt11InvoiceFeatures } from '../structs/Bolt11InvoiceFeatures.mjs';
159 import { Result_Bolt11InvoiceFeaturesDecodeErrorZ } from '../structs/Result_Bolt11InvoiceFeaturesDecodeErrorZ.mjs';
160 import { Bolt12InvoiceFeatures } from '../structs/Bolt12InvoiceFeatures.mjs';
161 import { Result_Bolt12InvoiceFeaturesDecodeErrorZ } from '../structs/Result_Bolt12InvoiceFeaturesDecodeErrorZ.mjs';
162 import { BlindedHopFeatures } from '../structs/BlindedHopFeatures.mjs';
163 import { Result_BlindedHopFeaturesDecodeErrorZ } from '../structs/Result_BlindedHopFeaturesDecodeErrorZ.mjs';
164 import { ChannelTypeFeatures } from '../structs/ChannelTypeFeatures.mjs';
165 import { Result_ChannelTypeFeaturesDecodeErrorZ } from '../structs/Result_ChannelTypeFeaturesDecodeErrorZ.mjs';
166 import { OfferId } from '../structs/OfferId.mjs';
167 import { Result_OfferIdDecodeErrorZ } from '../structs/Result_OfferIdDecodeErrorZ.mjs';
168 import { Result_NoneBolt12SemanticErrorZ } from '../structs/Result_NoneBolt12SemanticErrorZ.mjs';
169 import { Offer } from '../structs/Offer.mjs';
170 import { Result_OfferBolt12SemanticErrorZ } from '../structs/Result_OfferBolt12SemanticErrorZ.mjs';
171 import { InvoiceRequestWithDerivedPayerIdBuilder } from '../structs/InvoiceRequestWithDerivedPayerIdBuilder.mjs';
172 import { Result_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ } from '../structs/Result_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ.mjs';
173 import { InvoiceRequestWithExplicitPayerIdBuilder } from '../structs/InvoiceRequestWithExplicitPayerIdBuilder.mjs';
174 import { Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ } from '../structs/Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ.mjs';
175 import { Result_OfferBolt12ParseErrorZ } from '../structs/Result_OfferBolt12ParseErrorZ.mjs';
176 import { Result_NodeIdDecodeErrorZ } from '../structs/Result_NodeIdDecodeErrorZ.mjs';
177 import { Result_PublicKeySecp256k1ErrorZ } from '../structs/Result_PublicKeySecp256k1ErrorZ.mjs';
178 import { ChannelUpdate } from '../structs/ChannelUpdate.mjs';
179 import { NetworkUpdate } from '../structs/NetworkUpdate.mjs';
180 import { Option_NetworkUpdateZ } from '../structs/Option_NetworkUpdateZ.mjs';
181 import { Result_COption_NetworkUpdateZDecodeErrorZ } from '../structs/Result_COption_NetworkUpdateZDecodeErrorZ.mjs';
182 import { Result_TxOutUtxoLookupErrorZ } from '../structs/Result_TxOutUtxoLookupErrorZ.mjs';
183 import { UtxoFuture } from '../structs/UtxoFuture.mjs';
184 import { UtxoResult } from '../structs/UtxoResult.mjs';
185 import { UtxoLookup, UtxoLookupInterface } from '../structs/UtxoLookup.mjs';
186 import { Option_UtxoLookupZ } from '../structs/Option_UtxoLookupZ.mjs';
187 import { Result_NoneLightningErrorZ } from '../structs/Result_NoneLightningErrorZ.mjs';
188 import { Result_boolLightningErrorZ } from '../structs/Result_boolLightningErrorZ.mjs';
189 import { ChannelAnnouncement } from '../structs/ChannelAnnouncement.mjs';
190 import { ThreeTuple_ChannelAnnouncementChannelUpdateChannelUpdateZ } from '../structs/ThreeTuple_ChannelAnnouncementChannelUpdateChannelUpdateZ.mjs';
191 import { Option_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ } from '../structs/Option_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ.mjs';
192 import { AcceptChannel } from '../structs/AcceptChannel.mjs';
193 import { AcceptChannelV2 } from '../structs/AcceptChannelV2.mjs';
194 import { OpenChannel } from '../structs/OpenChannel.mjs';
195 import { OpenChannelV2 } from '../structs/OpenChannelV2.mjs';
196 import { FundingCreated } from '../structs/FundingCreated.mjs';
197 import { FundingSigned } from '../structs/FundingSigned.mjs';
198 import { Stfu } from '../structs/Stfu.mjs';
199 import { Splice } from '../structs/Splice.mjs';
200 import { SpliceAck } from '../structs/SpliceAck.mjs';
201 import { SpliceLocked } from '../structs/SpliceLocked.mjs';
202 import { TxAddInput } from '../structs/TxAddInput.mjs';
203 import { TxAddOutput } from '../structs/TxAddOutput.mjs';
204 import { TxRemoveInput } from '../structs/TxRemoveInput.mjs';
205 import { TxRemoveOutput } from '../structs/TxRemoveOutput.mjs';
206 import { TxComplete } from '../structs/TxComplete.mjs';
207 import { TxSignatures } from '../structs/TxSignatures.mjs';
208 import { TxInitRbf } from '../structs/TxInitRbf.mjs';
209 import { TxAckRbf } from '../structs/TxAckRbf.mjs';
210 import { TxAbort } from '../structs/TxAbort.mjs';
211 import { ChannelReady } from '../structs/ChannelReady.mjs';
212 import { AnnouncementSignatures } from '../structs/AnnouncementSignatures.mjs';
213 import { CommitmentUpdate } from '../structs/CommitmentUpdate.mjs';
214 import { RevokeAndACK } from '../structs/RevokeAndACK.mjs';
215 import { ClosingSigned } from '../structs/ClosingSigned.mjs';
216 import { Shutdown } from '../structs/Shutdown.mjs';
217 import { ChannelReestablish } from '../structs/ChannelReestablish.mjs';
218 import { NodeAnnouncement } from '../structs/NodeAnnouncement.mjs';
219 import { ErrorMessage } from '../structs/ErrorMessage.mjs';
220 import { WarningMessage } from '../structs/WarningMessage.mjs';
221 import { ErrorAction } from '../structs/ErrorAction.mjs';
222 import { QueryChannelRange } from '../structs/QueryChannelRange.mjs';
223 import { QueryShortChannelIds } from '../structs/QueryShortChannelIds.mjs';
224 import { ReplyChannelRange } from '../structs/ReplyChannelRange.mjs';
225 import { GossipTimestampFilter } from '../structs/GossipTimestampFilter.mjs';
226 import { MessageSendEvent } from '../structs/MessageSendEvent.mjs';
227 import { ChannelUpdateInfo } from '../structs/ChannelUpdateInfo.mjs';
228 import { Result_ChannelUpdateInfoDecodeErrorZ } from '../structs/Result_ChannelUpdateInfoDecodeErrorZ.mjs';
229 import { ChannelInfo } from '../structs/ChannelInfo.mjs';
230 import { Result_ChannelInfoDecodeErrorZ } from '../structs/Result_ChannelInfoDecodeErrorZ.mjs';
231 import { RoutingFees } from '../structs/RoutingFees.mjs';
232 import { Result_RoutingFeesDecodeErrorZ } from '../structs/Result_RoutingFeesDecodeErrorZ.mjs';
233 import { Hostname } from '../structs/Hostname.mjs';
234 import { SocketAddress } from '../structs/SocketAddress.mjs';
235 import { NodeAnnouncementInfo } from '../structs/NodeAnnouncementInfo.mjs';
236 import { Result_NodeAnnouncementInfoDecodeErrorZ } from '../structs/Result_NodeAnnouncementInfoDecodeErrorZ.mjs';
237 import { NodeAlias } from '../structs/NodeAlias.mjs';
238 import { Result_NodeAliasDecodeErrorZ } from '../structs/Result_NodeAliasDecodeErrorZ.mjs';
239 import { NodeInfo } from '../structs/NodeInfo.mjs';
240 import { Result_NodeInfoDecodeErrorZ } from '../structs/Result_NodeInfoDecodeErrorZ.mjs';
241 import { Result_NetworkGraphDecodeErrorZ } from '../structs/Result_NetworkGraphDecodeErrorZ.mjs';
242 import { Option_CVec_SocketAddressZZ } from '../structs/Option_CVec_SocketAddressZZ.mjs';
243 import { Result_u64ShortChannelIdErrorZ } from '../structs/Result_u64ShortChannelIdErrorZ.mjs';
244 import { PendingHTLCInfo } from '../structs/PendingHTLCInfo.mjs';
245 import { InboundHTLCErr } from '../structs/InboundHTLCErr.mjs';
246 import { Result_PendingHTLCInfoInboundHTLCErrZ } from '../structs/Result_PendingHTLCInfoInboundHTLCErrZ.mjs';
247 import { Utxo } from '../structs/Utxo.mjs';
248 import { Option_TxOutZ } from '../structs/Option_TxOutZ.mjs';
249 import { Input } from '../structs/Input.mjs';
250 import { CoinSelection } from '../structs/CoinSelection.mjs';
251 import { Result_CoinSelectionNoneZ } from '../structs/Result_CoinSelectionNoneZ.mjs';
252 import { Result_CVec_UtxoZNoneZ } from '../structs/Result_CVec_UtxoZNoneZ.mjs';
253 import { UnknownPaymentContext } from '../structs/UnknownPaymentContext.mjs';
254 import { Bolt12OfferContext } from '../structs/Bolt12OfferContext.mjs';
255 import { Bolt12RefundContext } from '../structs/Bolt12RefundContext.mjs';
256 import { PaymentContext } from '../structs/PaymentContext.mjs';
257 import { Option_PaymentContextZ } from '../structs/Option_PaymentContextZ.mjs';
258 import { TwoTuple_u64u16Z } from '../structs/TwoTuple_u64u16Z.mjs';
259 import { Option_C2Tuple_u64u16ZZ } from '../structs/Option_C2Tuple_u64u16ZZ.mjs';
260 import { Option_ChannelShutdownStateZ } from '../structs/Option_ChannelShutdownStateZ.mjs';
261 import { Result_ChannelIdAPIErrorZ } from '../structs/Result_ChannelIdAPIErrorZ.mjs';
262 import { RecentPaymentDetails } from '../structs/RecentPaymentDetails.mjs';
263 import { PaymentSendFailure } from '../structs/PaymentSendFailure.mjs';
264 import { Result_NonePaymentSendFailureZ } from '../structs/Result_NonePaymentSendFailureZ.mjs';
265 import { Result_NoneRetryableSendFailureZ } from '../structs/Result_NoneRetryableSendFailureZ.mjs';
266 import { Result_ThirtyTwoBytesPaymentSendFailureZ } from '../structs/Result_ThirtyTwoBytesPaymentSendFailureZ.mjs';
267 import { Result_ThirtyTwoBytesRetryableSendFailureZ } from '../structs/Result_ThirtyTwoBytesRetryableSendFailureZ.mjs';
268 import { TwoTuple_ThirtyTwoBytesThirtyTwoBytesZ } from '../structs/TwoTuple_ThirtyTwoBytesThirtyTwoBytesZ.mjs';
269 import { Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ.mjs';
270 import { ProbeSendFailure } from '../structs/ProbeSendFailure.mjs';
271 import { Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ } from '../structs/Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.mjs';
272 import { TwoTuple_ChannelIdPublicKeyZ } from '../structs/TwoTuple_ChannelIdPublicKeyZ.mjs';
273 import { OfferWithDerivedMetadataBuilder } from '../structs/OfferWithDerivedMetadataBuilder.mjs';
274 import { Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ } from '../structs/Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ.mjs';
275 import { Option_StrZ } from '../structs/Option_StrZ.mjs';
276 import { Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.mjs';
277 import { Result_ThirtyTwoBytesAPIErrorZ } from '../structs/Result_ThirtyTwoBytesAPIErrorZ.mjs';
278 import { InvoiceRequest } from '../structs/InvoiceRequest.mjs';
279 import { InvoiceError } from '../structs/InvoiceError.mjs';
280 import { OffersMessage } from '../structs/OffersMessage.mjs';
281 import { Option_OffersMessageZ } from '../structs/Option_OffersMessageZ.mjs';
282 import { Destination } from '../structs/Destination.mjs';
283 import { ThreeTuple_OffersMessageDestinationBlindedPathZ } from '../structs/ThreeTuple_OffersMessageDestinationBlindedPathZ.mjs';
284 import { CounterpartyForwardingInfo } from '../structs/CounterpartyForwardingInfo.mjs';
285 import { Result_CounterpartyForwardingInfoDecodeErrorZ } from '../structs/Result_CounterpartyForwardingInfoDecodeErrorZ.mjs';
286 import { ChannelCounterparty } from '../structs/ChannelCounterparty.mjs';
287 import { Result_ChannelCounterpartyDecodeErrorZ } from '../structs/Result_ChannelCounterpartyDecodeErrorZ.mjs';
288 import { Result_ChannelDetailsDecodeErrorZ } from '../structs/Result_ChannelDetailsDecodeErrorZ.mjs';
289 import { PhantomRouteHints } from '../structs/PhantomRouteHints.mjs';
290 import { Result_PhantomRouteHintsDecodeErrorZ } from '../structs/Result_PhantomRouteHintsDecodeErrorZ.mjs';
291 import { BlindedForward } from '../structs/BlindedForward.mjs';
292 import { Result_BlindedForwardDecodeErrorZ } from '../structs/Result_BlindedForwardDecodeErrorZ.mjs';
293 import { OnionPacket } from '../structs/OnionPacket.mjs';
294 import { FinalOnionHopData } from '../structs/FinalOnionHopData.mjs';
295 import { PendingHTLCRouting } from '../structs/PendingHTLCRouting.mjs';
296 import { Result_PendingHTLCRoutingDecodeErrorZ } from '../structs/Result_PendingHTLCRoutingDecodeErrorZ.mjs';
297 import { Result_PendingHTLCInfoDecodeErrorZ } from '../structs/Result_PendingHTLCInfoDecodeErrorZ.mjs';
298 import { Result_BlindedFailureDecodeErrorZ } from '../structs/Result_BlindedFailureDecodeErrorZ.mjs';
299 import { Result_ChannelShutdownStateDecodeErrorZ } from '../structs/Result_ChannelShutdownStateDecodeErrorZ.mjs';
300 import { ChannelMonitor } from '../structs/ChannelMonitor.mjs';
301 import { ChannelMonitorUpdate } from '../structs/ChannelMonitorUpdate.mjs';
302 import { Watch, WatchInterface } from '../structs/Watch.mjs';
303 import { BroadcasterInterface, BroadcasterInterfaceInterface } from '../structs/BroadcasterInterface.mjs';
304 import { EntropySource, EntropySourceInterface } from '../structs/EntropySource.mjs';
305 import { UnsignedInvoiceRequest } from '../structs/UnsignedInvoiceRequest.mjs';
306 import { UnsignedChannelUpdate } from '../structs/UnsignedChannelUpdate.mjs';
307 import { UnsignedNodeAnnouncement } from '../structs/UnsignedNodeAnnouncement.mjs';
308 import { UnsignedGossipMessage } from '../structs/UnsignedGossipMessage.mjs';
309 import { NodeSigner, NodeSignerInterface } from '../structs/NodeSigner.mjs';
310 import { SignerProvider, SignerProviderInterface } from '../structs/SignerProvider.mjs';
311 import { FeeEstimator, FeeEstimatorInterface } from '../structs/FeeEstimator.mjs';
312 import { ReceiveTlvs } from '../structs/ReceiveTlvs.mjs';
313 import { MessageRouter, MessageRouterInterface } from '../structs/MessageRouter.mjs';
314 import { Router, RouterInterface } from '../structs/Router.mjs';
315 import { TwoTuple_ThirtyTwoBytesChannelManagerZ } from '../structs/TwoTuple_ThirtyTwoBytesChannelManagerZ.mjs';
316 import { Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.mjs';
317 import { MaxDustHTLCExposure } from '../structs/MaxDustHTLCExposure.mjs';
318 import { Result_MaxDustHTLCExposureDecodeErrorZ } from '../structs/Result_MaxDustHTLCExposureDecodeErrorZ.mjs';
319 import { ChannelConfig } from '../structs/ChannelConfig.mjs';
320 import { Result_ChannelConfigDecodeErrorZ } from '../structs/Result_ChannelConfigDecodeErrorZ.mjs';
321 import { Option_MaxDustHTLCExposureZ } from '../structs/Option_MaxDustHTLCExposureZ.mjs';
322 import { Option_APIErrorZ } from '../structs/Option_APIErrorZ.mjs';
323 import { Result_COption_APIErrorZDecodeErrorZ } from '../structs/Result_COption_APIErrorZDecodeErrorZ.mjs';
324 import { Result_ChannelMonitorUpdateDecodeErrorZ } from '../structs/Result_ChannelMonitorUpdateDecodeErrorZ.mjs';
325 import { Option_MonitorEventZ } from '../structs/Option_MonitorEventZ.mjs';
326 import { Result_COption_MonitorEventZDecodeErrorZ } from '../structs/Result_COption_MonitorEventZDecodeErrorZ.mjs';
327 import { Result_HTLCUpdateDecodeErrorZ } from '../structs/Result_HTLCUpdateDecodeErrorZ.mjs';
328 import { TwoTuple_OutPointCVec_u8ZZ } from '../structs/TwoTuple_OutPointCVec_u8ZZ.mjs';
329 import { TwoTuple_u32CVec_u8ZZ } from '../structs/TwoTuple_u32CVec_u8ZZ.mjs';
330 import { TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ } from '../structs/TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ.mjs';
331 import { TwoTuple_u32TxOutZ } from '../structs/TwoTuple_u32TxOutZ.mjs';
332 import { TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ } from '../structs/TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ.mjs';
333 import { Balance } from '../structs/Balance.mjs';
334 import { TwoTuple_ThirtyTwoBytesChannelMonitorZ } from '../structs/TwoTuple_ThirtyTwoBytesChannelMonitorZ.mjs';
335 import { Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.mjs';
336 import { Type, TypeInterface } from '../structs/Type.mjs';
337 import { TwoTuple_PublicKeyTypeZ } from '../structs/TwoTuple_PublicKeyTypeZ.mjs';
338 import { TwoTuple_PublicKeyCVec_SocketAddressZZ } from '../structs/TwoTuple_PublicKeyCVec_SocketAddressZZ.mjs';
339 import { OnionMessageContents, OnionMessageContentsInterface } from '../structs/OnionMessageContents.mjs';
340 import { Option_OnionMessageContentsZ } from '../structs/Option_OnionMessageContentsZ.mjs';
341 import { Result_COption_OnionMessageContentsZDecodeErrorZ } from '../structs/Result_COption_OnionMessageContentsZDecodeErrorZ.mjs';
342 import { ThreeTuple_OnionMessageContentsDestinationBlindedPathZ } from '../structs/ThreeTuple_OnionMessageContentsDestinationBlindedPathZ.mjs';
343 import { Option_TypeZ } from '../structs/Option_TypeZ.mjs';
344 import { Result_COption_TypeZDecodeErrorZ } from '../structs/Result_COption_TypeZDecodeErrorZ.mjs';
345 import { Option_SocketAddressZ } from '../structs/Option_SocketAddressZ.mjs';
346 import { PeerDetails } from '../structs/PeerDetails.mjs';
347 import { PeerHandleError } from '../structs/PeerHandleError.mjs';
348 import { Result_CVec_u8ZPeerHandleErrorZ } from '../structs/Result_CVec_u8ZPeerHandleErrorZ.mjs';
349 import { Result_NonePeerHandleErrorZ } from '../structs/Result_NonePeerHandleErrorZ.mjs';
350 import { Result_boolPeerHandleErrorZ } from '../structs/Result_boolPeerHandleErrorZ.mjs';
351 import { GraphSyncError } from '../structs/GraphSyncError.mjs';
352 import { Result_u32GraphSyncErrorZ } from '../structs/Result_u32GraphSyncErrorZ.mjs';
353 import { Result_CVec_u8ZIOErrorZ } from '../structs/Result_CVec_u8ZIOErrorZ.mjs';
354 import { Result_NoneIOErrorZ } from '../structs/Result_NoneIOErrorZ.mjs';
355 import { Result_CVec_StrZIOErrorZ } from '../structs/Result_CVec_StrZIOErrorZ.mjs';
356 import { Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ } from '../structs/Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ.mjs';
357 import { Result_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ.mjs';
358 import { Result_UnsignedInvoiceRequestBolt12SemanticErrorZ } from '../structs/Result_UnsignedInvoiceRequestBolt12SemanticErrorZ.mjs';
359 import { Result_InvoiceRequestBolt12SemanticErrorZ } from '../structs/Result_InvoiceRequestBolt12SemanticErrorZ.mjs';
360 import { Option_SecretKeyZ } from '../structs/Option_SecretKeyZ.mjs';
361 import { InvoiceWithExplicitSigningPubkeyBuilder } from '../structs/InvoiceWithExplicitSigningPubkeyBuilder.mjs';
362 import { Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ } from '../structs/Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ.mjs';
363 import { VerifiedInvoiceRequest } from '../structs/VerifiedInvoiceRequest.mjs';
364 import { Result_VerifiedInvoiceRequestNoneZ } from '../structs/Result_VerifiedInvoiceRequestNoneZ.mjs';
365 import { InvoiceWithDerivedSigningPubkeyBuilder } from '../structs/InvoiceWithDerivedSigningPubkeyBuilder.mjs';
366 import { Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ } from '../structs/Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ.mjs';
367 import { InvoiceRequestFields } from '../structs/InvoiceRequestFields.mjs';
368 import { Result_InvoiceRequestFieldsDecodeErrorZ } from '../structs/Result_InvoiceRequestFieldsDecodeErrorZ.mjs';
369 import { Option_ECDSASignatureZ } from '../structs/Option_ECDSASignatureZ.mjs';
370 import { Option_i64Z } from '../structs/Option_i64Z.mjs';
371 import { Result_SocketAddressDecodeErrorZ } from '../structs/Result_SocketAddressDecodeErrorZ.mjs';
372 import { Result_SocketAddressSocketAddressParseErrorZ } from '../structs/Result_SocketAddressSocketAddressParseErrorZ.mjs';
373 import { UpdateAddHTLC } from '../structs/UpdateAddHTLC.mjs';
374 import { UpdateFulfillHTLC } from '../structs/UpdateFulfillHTLC.mjs';
375 import { UpdateFailHTLC } from '../structs/UpdateFailHTLC.mjs';
376 import { UpdateFailMalformedHTLC } from '../structs/UpdateFailMalformedHTLC.mjs';
377 import { Result_AcceptChannelDecodeErrorZ } from '../structs/Result_AcceptChannelDecodeErrorZ.mjs';
378 import { Result_AcceptChannelV2DecodeErrorZ } from '../structs/Result_AcceptChannelV2DecodeErrorZ.mjs';
379 import { Result_StfuDecodeErrorZ } from '../structs/Result_StfuDecodeErrorZ.mjs';
380 import { Result_SpliceDecodeErrorZ } from '../structs/Result_SpliceDecodeErrorZ.mjs';
381 import { Result_SpliceAckDecodeErrorZ } from '../structs/Result_SpliceAckDecodeErrorZ.mjs';
382 import { Result_SpliceLockedDecodeErrorZ } from '../structs/Result_SpliceLockedDecodeErrorZ.mjs';
383 import { Result_TxAddInputDecodeErrorZ } from '../structs/Result_TxAddInputDecodeErrorZ.mjs';
384 import { Result_TxAddOutputDecodeErrorZ } from '../structs/Result_TxAddOutputDecodeErrorZ.mjs';
385 import { Result_TxRemoveInputDecodeErrorZ } from '../structs/Result_TxRemoveInputDecodeErrorZ.mjs';
386 import { Result_TxRemoveOutputDecodeErrorZ } from '../structs/Result_TxRemoveOutputDecodeErrorZ.mjs';
387 import { Result_TxCompleteDecodeErrorZ } from '../structs/Result_TxCompleteDecodeErrorZ.mjs';
388 import { Result_TxSignaturesDecodeErrorZ } from '../structs/Result_TxSignaturesDecodeErrorZ.mjs';
389 import { Result_TxInitRbfDecodeErrorZ } from '../structs/Result_TxInitRbfDecodeErrorZ.mjs';
390 import { Result_TxAckRbfDecodeErrorZ } from '../structs/Result_TxAckRbfDecodeErrorZ.mjs';
391 import { Result_TxAbortDecodeErrorZ } from '../structs/Result_TxAbortDecodeErrorZ.mjs';
392 import { Result_AnnouncementSignaturesDecodeErrorZ } from '../structs/Result_AnnouncementSignaturesDecodeErrorZ.mjs';
393 import { Result_ChannelReestablishDecodeErrorZ } from '../structs/Result_ChannelReestablishDecodeErrorZ.mjs';
394 import { Result_ClosingSignedDecodeErrorZ } from '../structs/Result_ClosingSignedDecodeErrorZ.mjs';
395 import { ClosingSignedFeeRange } from '../structs/ClosingSignedFeeRange.mjs';
396 import { Result_ClosingSignedFeeRangeDecodeErrorZ } from '../structs/Result_ClosingSignedFeeRangeDecodeErrorZ.mjs';
397 import { CommitmentSigned } from '../structs/CommitmentSigned.mjs';
398 import { Result_CommitmentSignedDecodeErrorZ } from '../structs/Result_CommitmentSignedDecodeErrorZ.mjs';
399 import { Result_FundingCreatedDecodeErrorZ } from '../structs/Result_FundingCreatedDecodeErrorZ.mjs';
400 import { Result_FundingSignedDecodeErrorZ } from '../structs/Result_FundingSignedDecodeErrorZ.mjs';
401 import { Result_ChannelReadyDecodeErrorZ } from '../structs/Result_ChannelReadyDecodeErrorZ.mjs';
402 import { Init } from '../structs/Init.mjs';
403 import { Result_InitDecodeErrorZ } from '../structs/Result_InitDecodeErrorZ.mjs';
404 import { Result_OpenChannelDecodeErrorZ } from '../structs/Result_OpenChannelDecodeErrorZ.mjs';
405 import { Result_OpenChannelV2DecodeErrorZ } from '../structs/Result_OpenChannelV2DecodeErrorZ.mjs';
406 import { Result_RevokeAndACKDecodeErrorZ } from '../structs/Result_RevokeAndACKDecodeErrorZ.mjs';
407 import { Result_ShutdownDecodeErrorZ } from '../structs/Result_ShutdownDecodeErrorZ.mjs';
408 import { Result_UpdateFailHTLCDecodeErrorZ } from '../structs/Result_UpdateFailHTLCDecodeErrorZ.mjs';
409 import { Result_UpdateFailMalformedHTLCDecodeErrorZ } from '../structs/Result_UpdateFailMalformedHTLCDecodeErrorZ.mjs';
410 import { UpdateFee } from '../structs/UpdateFee.mjs';
411 import { Result_UpdateFeeDecodeErrorZ } from '../structs/Result_UpdateFeeDecodeErrorZ.mjs';
412 import { Result_UpdateFulfillHTLCDecodeErrorZ } from '../structs/Result_UpdateFulfillHTLCDecodeErrorZ.mjs';
413 import { Result_OnionPacketDecodeErrorZ } from '../structs/Result_OnionPacketDecodeErrorZ.mjs';
414 import { Result_UpdateAddHTLCDecodeErrorZ } from '../structs/Result_UpdateAddHTLCDecodeErrorZ.mjs';
415 import { OnionMessage } from '../structs/OnionMessage.mjs';
416 import { Result_OnionMessageDecodeErrorZ } from '../structs/Result_OnionMessageDecodeErrorZ.mjs';
417 import { Result_FinalOnionHopDataDecodeErrorZ } from '../structs/Result_FinalOnionHopDataDecodeErrorZ.mjs';
418 import { Ping } from '../structs/Ping.mjs';
419 import { Result_PingDecodeErrorZ } from '../structs/Result_PingDecodeErrorZ.mjs';
420 import { Pong } from '../structs/Pong.mjs';
421 import { Result_PongDecodeErrorZ } from '../structs/Result_PongDecodeErrorZ.mjs';
422 import { Result_UnsignedChannelAnnouncementDecodeErrorZ } from '../structs/Result_UnsignedChannelAnnouncementDecodeErrorZ.mjs';
423 import { Result_ChannelAnnouncementDecodeErrorZ } from '../structs/Result_ChannelAnnouncementDecodeErrorZ.mjs';
424 import { Result_UnsignedChannelUpdateDecodeErrorZ } from '../structs/Result_UnsignedChannelUpdateDecodeErrorZ.mjs';
425 import { Result_ChannelUpdateDecodeErrorZ } from '../structs/Result_ChannelUpdateDecodeErrorZ.mjs';
426 import { Result_ErrorMessageDecodeErrorZ } from '../structs/Result_ErrorMessageDecodeErrorZ.mjs';
427 import { Result_WarningMessageDecodeErrorZ } from '../structs/Result_WarningMessageDecodeErrorZ.mjs';
428 import { Result_UnsignedNodeAnnouncementDecodeErrorZ } from '../structs/Result_UnsignedNodeAnnouncementDecodeErrorZ.mjs';
429 import { Result_NodeAnnouncementDecodeErrorZ } from '../structs/Result_NodeAnnouncementDecodeErrorZ.mjs';
430 import { Result_QueryShortChannelIdsDecodeErrorZ } from '../structs/Result_QueryShortChannelIdsDecodeErrorZ.mjs';
431 import { ReplyShortChannelIdsEnd } from '../structs/ReplyShortChannelIdsEnd.mjs';
432 import { Result_ReplyShortChannelIdsEndDecodeErrorZ } from '../structs/Result_ReplyShortChannelIdsEndDecodeErrorZ.mjs';
433 import { Result_QueryChannelRangeDecodeErrorZ } from '../structs/Result_QueryChannelRangeDecodeErrorZ.mjs';
434 import { Result_ReplyChannelRangeDecodeErrorZ } from '../structs/Result_ReplyChannelRangeDecodeErrorZ.mjs';
435 import { Result_GossipTimestampFilterDecodeErrorZ } from '../structs/Result_GossipTimestampFilterDecodeErrorZ.mjs';
436 import { Bolt11Invoice } from '../structs/Bolt11Invoice.mjs';
437 import { SignOrCreationError } from '../structs/SignOrCreationError.mjs';
438 import { Result_Bolt11InvoiceSignOrCreationErrorZ } from '../structs/Result_Bolt11InvoiceSignOrCreationErrorZ.mjs';
439 import { Result_OffersMessageDecodeErrorZ } from '../structs/Result_OffersMessageDecodeErrorZ.mjs';
440 import { Option_HTLCClaimZ } from '../structs/Option_HTLCClaimZ.mjs';
441 import { CounterpartyCommitmentSecrets } from '../structs/CounterpartyCommitmentSecrets.mjs';
442 import { Result_CounterpartyCommitmentSecretsDecodeErrorZ } from '../structs/Result_CounterpartyCommitmentSecretsDecodeErrorZ.mjs';
443 import { TxCreationKeys } from '../structs/TxCreationKeys.mjs';
444 import { Result_TxCreationKeysDecodeErrorZ } from '../structs/Result_TxCreationKeysDecodeErrorZ.mjs';
445 import { Result_ChannelPublicKeysDecodeErrorZ } from '../structs/Result_ChannelPublicKeysDecodeErrorZ.mjs';
446 import { Result_HTLCOutputInCommitmentDecodeErrorZ } from '../structs/Result_HTLCOutputInCommitmentDecodeErrorZ.mjs';
447 import { CounterpartyChannelTransactionParameters } from '../structs/CounterpartyChannelTransactionParameters.mjs';
448 import { Result_CounterpartyChannelTransactionParametersDecodeErrorZ } from '../structs/Result_CounterpartyChannelTransactionParametersDecodeErrorZ.mjs';
449 import { Result_ChannelTransactionParametersDecodeErrorZ } from '../structs/Result_ChannelTransactionParametersDecodeErrorZ.mjs';
450 import { Result_HolderCommitmentTransactionDecodeErrorZ } from '../structs/Result_HolderCommitmentTransactionDecodeErrorZ.mjs';
451 import { BuiltCommitmentTransaction } from '../structs/BuiltCommitmentTransaction.mjs';
452 import { Result_BuiltCommitmentTransactionDecodeErrorZ } from '../structs/Result_BuiltCommitmentTransactionDecodeErrorZ.mjs';
453 import { TrustedClosingTransaction } from '../structs/TrustedClosingTransaction.mjs';
454 import { Result_TrustedClosingTransactionNoneZ } from '../structs/Result_TrustedClosingTransactionNoneZ.mjs';
455 import { Result_CommitmentTransactionDecodeErrorZ } from '../structs/Result_CommitmentTransactionDecodeErrorZ.mjs';
456 import { TrustedCommitmentTransaction } from '../structs/TrustedCommitmentTransaction.mjs';
457 import { Result_TrustedCommitmentTransactionNoneZ } from '../structs/Result_TrustedCommitmentTransactionNoneZ.mjs';
458 import { Result_CVec_ECDSASignatureZNoneZ } from '../structs/Result_CVec_ECDSASignatureZNoneZ.mjs';
459 import { Option_usizeZ } from '../structs/Option_usizeZ.mjs';
460 import { Result_ShutdownScriptDecodeErrorZ } from '../structs/Result_ShutdownScriptDecodeErrorZ.mjs';
461 import { InvalidShutdownScript } from '../structs/InvalidShutdownScript.mjs';
462 import { Result_ShutdownScriptInvalidShutdownScriptZ } from '../structs/Result_ShutdownScriptInvalidShutdownScriptZ.mjs';
463 import { PaymentPurpose } from '../structs/PaymentPurpose.mjs';
464 import { Result_PaymentPurposeDecodeErrorZ } from '../structs/Result_PaymentPurposeDecodeErrorZ.mjs';
465 import { ClaimedHTLC } from '../structs/ClaimedHTLC.mjs';
466 import { Result_ClaimedHTLCDecodeErrorZ } from '../structs/Result_ClaimedHTLCDecodeErrorZ.mjs';
467 import { PathFailure } from '../structs/PathFailure.mjs';
468 import { Option_PathFailureZ } from '../structs/Option_PathFailureZ.mjs';
469 import { Result_COption_PathFailureZDecodeErrorZ } from '../structs/Result_COption_PathFailureZDecodeErrorZ.mjs';
470 import { Option_ClosureReasonZ } from '../structs/Option_ClosureReasonZ.mjs';
471 import { Result_COption_ClosureReasonZDecodeErrorZ } from '../structs/Result_COption_ClosureReasonZDecodeErrorZ.mjs';
472 import { HTLCDestination } from '../structs/HTLCDestination.mjs';
473 import { Option_HTLCDestinationZ } from '../structs/Option_HTLCDestinationZ.mjs';
474 import { Result_COption_HTLCDestinationZDecodeErrorZ } from '../structs/Result_COption_HTLCDestinationZDecodeErrorZ.mjs';
475 import { Result_PaymentFailureReasonDecodeErrorZ } from '../structs/Result_PaymentFailureReasonDecodeErrorZ.mjs';
476 import { Option_U128Z } from '../structs/Option_U128Z.mjs';
477 import { Option_PaymentFailureReasonZ } from '../structs/Option_PaymentFailureReasonZ.mjs';
478 import { AnchorDescriptor } from '../structs/AnchorDescriptor.mjs';
479 import { BumpTransactionEvent } from '../structs/BumpTransactionEvent.mjs';
480 import { Event } from '../structs/Event.mjs';
481 import { Option_EventZ } from '../structs/Option_EventZ.mjs';
482 import { Result_COption_EventZDecodeErrorZ } from '../structs/Result_COption_EventZDecodeErrorZ.mjs';
483 import { Bolt11ParseError } from '../structs/Bolt11ParseError.mjs';
484 import { Result_SiPrefixBolt11ParseErrorZ } from '../structs/Result_SiPrefixBolt11ParseErrorZ.mjs';
485 import { ParseOrSemanticError } from '../structs/ParseOrSemanticError.mjs';
486 import { Result_Bolt11InvoiceParseOrSemanticErrorZ } from '../structs/Result_Bolt11InvoiceParseOrSemanticErrorZ.mjs';
487 import { SignedRawBolt11Invoice } from '../structs/SignedRawBolt11Invoice.mjs';
488 import { Result_SignedRawBolt11InvoiceBolt11ParseErrorZ } from '../structs/Result_SignedRawBolt11InvoiceBolt11ParseErrorZ.mjs';
489 import { RawBolt11Invoice } from '../structs/RawBolt11Invoice.mjs';
490 import { Bolt11InvoiceSignature } from '../structs/Bolt11InvoiceSignature.mjs';
491 import { ThreeTuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ } from '../structs/ThreeTuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ.mjs';
492 import { PayeePubKey } from '../structs/PayeePubKey.mjs';
493 import { Result_PayeePubKeySecp256k1ErrorZ } from '../structs/Result_PayeePubKeySecp256k1ErrorZ.mjs';
494 import { PrivateRoute } from '../structs/PrivateRoute.mjs';
495 import { PositiveTimestamp } from '../structs/PositiveTimestamp.mjs';
496 import { Result_PositiveTimestampCreationErrorZ } from '../structs/Result_PositiveTimestampCreationErrorZ.mjs';
497 import { Result_NoneBolt11SemanticErrorZ } from '../structs/Result_NoneBolt11SemanticErrorZ.mjs';
498 import { Result_Bolt11InvoiceBolt11SemanticErrorZ } from '../structs/Result_Bolt11InvoiceBolt11SemanticErrorZ.mjs';
499 import { Description } from '../structs/Description.mjs';
500 import { Result_DescriptionCreationErrorZ } from '../structs/Result_DescriptionCreationErrorZ.mjs';
501 import { Result_PrivateRouteCreationErrorZ } from '../structs/Result_PrivateRouteCreationErrorZ.mjs';
502 import { Result_OutPointDecodeErrorZ } from '../structs/Result_OutPointDecodeErrorZ.mjs';
503 import { BigSize } from '../structs/BigSize.mjs';
504 import { Result_BigSizeDecodeErrorZ } from '../structs/Result_BigSizeDecodeErrorZ.mjs';
505 import { Result_HostnameDecodeErrorZ } from '../structs/Result_HostnameDecodeErrorZ.mjs';
506 import { TransactionU16LenLimited } from '../structs/TransactionU16LenLimited.mjs';
507 import { Result_TransactionU16LenLimitedNoneZ } from '../structs/Result_TransactionU16LenLimitedNoneZ.mjs';
508 import { Result_TransactionU16LenLimitedDecodeErrorZ } from '../structs/Result_TransactionU16LenLimitedDecodeErrorZ.mjs';
509 import { Result_UntrustedStringDecodeErrorZ } from '../structs/Result_UntrustedStringDecodeErrorZ.mjs';
510 import { Result_ChannelIdDecodeErrorZ } from '../structs/Result_ChannelIdDecodeErrorZ.mjs';
511 import { TwoTuple__u832u16Z } from '../structs/TwoTuple__u832u16Z.mjs';
512 import { PaymentRelay } from '../structs/PaymentRelay.mjs';
513 import { Result_PaymentRelayDecodeErrorZ } from '../structs/Result_PaymentRelayDecodeErrorZ.mjs';
514 import { PaymentConstraints } from '../structs/PaymentConstraints.mjs';
515 import { Result_PaymentConstraintsDecodeErrorZ } from '../structs/Result_PaymentConstraintsDecodeErrorZ.mjs';
516 import { Result_PaymentContextDecodeErrorZ } from '../structs/Result_PaymentContextDecodeErrorZ.mjs';
517 import { Result_UnknownPaymentContextDecodeErrorZ } from '../structs/Result_UnknownPaymentContextDecodeErrorZ.mjs';
518 import { Result_Bolt12OfferContextDecodeErrorZ } from '../structs/Result_Bolt12OfferContextDecodeErrorZ.mjs';
519 import { Result_Bolt12RefundContextDecodeErrorZ } from '../structs/Result_Bolt12RefundContextDecodeErrorZ.mjs';
520 import { Result_StrSecp256k1ErrorZ } from '../structs/Result_StrSecp256k1ErrorZ.mjs';
521 import { ThreeTuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ } from '../structs/ThreeTuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ.mjs';
522 import { Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ } from '../structs/Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.mjs';
523 import { ThreeTuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ } from '../structs/ThreeTuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ.mjs';
524 import { SendError } from '../structs/SendError.mjs';
525 import { Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ } from '../structs/Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.mjs';
526 import { NextMessageHop } from '../structs/NextMessageHop.mjs';
527 import { ParsedOnionMessageContents } from '../structs/ParsedOnionMessageContents.mjs';
528 import { PeeledOnion } from '../structs/PeeledOnion.mjs';
529 import { Result_PeeledOnionNoneZ } from '../structs/Result_PeeledOnionNoneZ.mjs';
530 import { SendSuccess } from '../structs/SendSuccess.mjs';
531 import { Result_SendSuccessSendErrorZ } from '../structs/Result_SendSuccessSendErrorZ.mjs';
532 import { Result_BlindedPathNoneZ } from '../structs/Result_BlindedPathNoneZ.mjs';
533 import { Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ } from '../structs/Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.mjs';
534 import { ForwardNode } from '../structs/ForwardNode.mjs';
535 import { Result_BlindedPathDecodeErrorZ } from '../structs/Result_BlindedPathDecodeErrorZ.mjs';
536 import { Result_BlindedHopDecodeErrorZ } from '../structs/Result_BlindedHopDecodeErrorZ.mjs';
537 import { Result_InvoiceErrorDecodeErrorZ } from '../structs/Result_InvoiceErrorDecodeErrorZ.mjs';
538 import { TrackedSpendableOutput } from '../structs/TrackedSpendableOutput.mjs';
539 import { Result_TrackedSpendableOutputDecodeErrorZ } from '../structs/Result_TrackedSpendableOutputDecodeErrorZ.mjs';
540 import { OutputSpendStatus } from '../structs/OutputSpendStatus.mjs';
541 import { Result_OutputSpendStatusDecodeErrorZ } from '../structs/Result_OutputSpendStatusDecodeErrorZ.mjs';
542 import { WatchedOutput } from '../structs/WatchedOutput.mjs';
543 import { Filter, FilterInterface } from '../structs/Filter.mjs';
544 import { Option_FilterZ } from '../structs/Option_FilterZ.mjs';
545 import { ChangeDestinationSource, ChangeDestinationSourceInterface } from '../structs/ChangeDestinationSource.mjs';
546 import { KVStore, KVStoreInterface } from '../structs/KVStore.mjs';
547 import { OutputSpender, OutputSpenderInterface } from '../structs/OutputSpender.mjs';
548 import { OutputSweeper } from '../structs/OutputSweeper.mjs';
549 import { Result_OutputSweeperDecodeErrorZ } from '../structs/Result_OutputSweeperDecodeErrorZ.mjs';
550 import { TwoTuple_BestBlockOutputSweeperZ } from '../structs/TwoTuple_BestBlockOutputSweeperZ.mjs';
551 import { Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ } from '../structs/Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ.mjs';
552 import { DelayedPaymentBasepoint } from '../structs/DelayedPaymentBasepoint.mjs';
553 import { Result_DelayedPaymentBasepointDecodeErrorZ } from '../structs/Result_DelayedPaymentBasepointDecodeErrorZ.mjs';
554 import { DelayedPaymentKey } from '../structs/DelayedPaymentKey.mjs';
555 import { Result_DelayedPaymentKeyDecodeErrorZ } from '../structs/Result_DelayedPaymentKeyDecodeErrorZ.mjs';
556 import { HtlcBasepoint } from '../structs/HtlcBasepoint.mjs';
557 import { Result_HtlcBasepointDecodeErrorZ } from '../structs/Result_HtlcBasepointDecodeErrorZ.mjs';
558 import { HtlcKey } from '../structs/HtlcKey.mjs';
559 import { Result_HtlcKeyDecodeErrorZ } from '../structs/Result_HtlcKeyDecodeErrorZ.mjs';
560 import { RevocationBasepoint } from '../structs/RevocationBasepoint.mjs';
561 import { Result_RevocationBasepointDecodeErrorZ } from '../structs/Result_RevocationBasepointDecodeErrorZ.mjs';
562 import { RevocationKey } from '../structs/RevocationKey.mjs';
563 import { Result_RevocationKeyDecodeErrorZ } from '../structs/Result_RevocationKeyDecodeErrorZ.mjs';
564 import { LockedChannelMonitor } from '../structs/LockedChannelMonitor.mjs';
565 import { Result_LockedChannelMonitorNoneZ } from '../structs/Result_LockedChannelMonitorNoneZ.mjs';
566 import { TwoTuple_OutPointChannelIdZ } from '../structs/TwoTuple_OutPointChannelIdZ.mjs';
567 import { MonitorUpdateId } from '../structs/MonitorUpdateId.mjs';
568 import { TwoTuple_OutPointCVec_MonitorUpdateIdZZ } from '../structs/TwoTuple_OutPointCVec_MonitorUpdateIdZZ.mjs';
569 import { FirstHopCandidate } from '../structs/FirstHopCandidate.mjs';
570 import { PublicHopCandidate } from '../structs/PublicHopCandidate.mjs';
571 import { PrivateHopCandidate } from '../structs/PrivateHopCandidate.mjs';
572 import { BlindedPathCandidate } from '../structs/BlindedPathCandidate.mjs';
573 import { OneHopBlindedPathCandidate } from '../structs/OneHopBlindedPathCandidate.mjs';
574 import { CandidateRouteHop } from '../structs/CandidateRouteHop.mjs';
575 import { ChannelUsage } from '../structs/ChannelUsage.mjs';
576 import { ProbabilisticScoringFeeParameters } from '../structs/ProbabilisticScoringFeeParameters.mjs';
577 import { ScoreLookUp, ScoreLookUpInterface } from '../structs/ScoreLookUp.mjs';
578 import { ScoreUpdate, ScoreUpdateInterface } from '../structs/ScoreUpdate.mjs';
579 import { LockableScore, LockableScoreInterface } from '../structs/LockableScore.mjs';
580 import { WriteableScore, WriteableScoreInterface } from '../structs/WriteableScore.mjs';
581 import { Persister, PersisterInterface } from '../structs/Persister.mjs';
582 import { MonitorUpdatingPersister } from '../structs/MonitorUpdatingPersister.mjs';
583 import { Persist, PersistInterface } from '../structs/Persist.mjs';
584 import { PrintableString } from '../structs/PrintableString.mjs';
585 import { Listen, ListenInterface } from '../structs/Listen.mjs';
586 import { Confirm, ConfirmInterface } from '../structs/Confirm.mjs';
587 import { SpendingDelay } from '../structs/SpendingDelay.mjs';
588 import { FutureCallback, FutureCallbackInterface } from '../structs/FutureCallback.mjs';
589 import { Future } from '../structs/Future.mjs';
590 import { ChannelHandshakeConfig } from '../structs/ChannelHandshakeConfig.mjs';
591 import { ChannelHandshakeLimits } from '../structs/ChannelHandshakeLimits.mjs';
592 import { ChannelConfigUpdate } from '../structs/ChannelConfigUpdate.mjs';
593 import { UserConfig } from '../structs/UserConfig.mjs';
594 import { ChainMonitor } from '../structs/ChainMonitor.mjs';
595 import { EventHandler, EventHandlerInterface } from '../structs/EventHandler.mjs';
596 import { EventsProvider, EventsProviderInterface } from '../structs/EventsProvider.mjs';
597 import { FailureCode } from '../structs/FailureCode.mjs';
598 import { ChainParameters } from '../structs/ChainParameters.mjs';
599 import { MessageSendEventsProvider, MessageSendEventsProviderInterface } from '../structs/MessageSendEventsProvider.mjs';
600 import { ChannelMessageHandler, ChannelMessageHandlerInterface } from '../structs/ChannelMessageHandler.mjs';
601 import { OffersMessageHandler, OffersMessageHandlerInterface } from '../structs/OffersMessageHandler.mjs';
602 import { NodeIdLookUp, NodeIdLookUpInterface } from '../structs/NodeIdLookUp.mjs';
603 import { ChannelManagerReadArgs } from '../structs/ChannelManagerReadArgs.mjs';
604 import { ExpandedKey } from '../structs/ExpandedKey.mjs';
605 import { CommonOpenChannelFields } from '../structs/CommonOpenChannelFields.mjs';
606 import { CommonAcceptChannelFields } from '../structs/CommonAcceptChannelFields.mjs';
607 import { Packet } from '../structs/Packet.mjs';
608 import { RoutingMessageHandler, RoutingMessageHandlerInterface } from '../structs/RoutingMessageHandler.mjs';
609 import { OnionMessageHandler, OnionMessageHandlerInterface } from '../structs/OnionMessageHandler.mjs';
610 import { TrampolineOnionPacket } from '../structs/TrampolineOnionPacket.mjs';
611 import { CustomMessageReader, CustomMessageReaderInterface } from '../structs/CustomMessageReader.mjs';
612 import { CustomMessageHandler, CustomMessageHandlerInterface } from '../structs/CustomMessageHandler.mjs';
613 import { IgnoringMessageHandler } from '../structs/IgnoringMessageHandler.mjs';
614 import { CustomOnionMessageHandler, CustomOnionMessageHandlerInterface } from '../structs/CustomOnionMessageHandler.mjs';
615 import { ErroringMessageHandler } from '../structs/ErroringMessageHandler.mjs';
616 import { MessageHandler } from '../structs/MessageHandler.mjs';
617 import { SocketDescriptor, SocketDescriptorInterface } from '../structs/SocketDescriptor.mjs';
618 import { PeerManager } from '../structs/PeerManager.mjs';
619 import { DirectedChannelTransactionParameters } from '../structs/DirectedChannelTransactionParameters.mjs';
620 import { OfferFeatures } from '../structs/OfferFeatures.mjs';
621 import { InvoiceRequestFeatures } from '../structs/InvoiceRequestFeatures.mjs';
622 import { OfferWithExplicitMetadataBuilder } from '../structs/OfferWithExplicitMetadataBuilder.mjs';
623 import { SignBolt12InvoiceFn, SignBolt12InvoiceFnInterface } from '../structs/SignBolt12InvoiceFn.mjs';
624 import { TaggedHash } from '../structs/TaggedHash.mjs';
625 import { ErroneousField } from '../structs/ErroneousField.mjs';
626 import { SignInvoiceRequestFn, SignInvoiceRequestFnInterface } from '../structs/SignInvoiceRequestFn.mjs';
627 import { SignError } from '../structs/SignError.mjs';
628 import { P2PGossipSync } from '../structs/P2PGossipSync.mjs';
629 import { ReadOnlyNetworkGraph } from '../structs/ReadOnlyNetworkGraph.mjs';
630 import { DirectedChannelInfo } from '../structs/DirectedChannelInfo.mjs';
631 import { EffectiveCapacity } from '../structs/EffectiveCapacity.mjs';
632 import { DefaultRouter } from '../structs/DefaultRouter.mjs';
633 import { ScorerAccountingForInFlightHtlcs } from '../structs/ScorerAccountingForInFlightHtlcs.mjs';
634 import { Payee } from '../structs/Payee.mjs';
635 import { Score, ScoreInterface } from '../structs/Score.mjs';
636 import { MultiThreadedLockableScore } from '../structs/MultiThreadedLockableScore.mjs';
637 import { MultiThreadedScoreLockRead } from '../structs/MultiThreadedScoreLockRead.mjs';
638 import { MultiThreadedScoreLockWrite } from '../structs/MultiThreadedScoreLockWrite.mjs';
639 import { ProbabilisticScoringDecayParameters } from '../structs/ProbabilisticScoringDecayParameters.mjs';
640 import { KeysManager } from '../structs/KeysManager.mjs';
641 import { PhantomKeysManager } from '../structs/PhantomKeysManager.mjs';
642 import { RandomBytes } from '../structs/RandomBytes.mjs';
643 import { OnionMessenger } from '../structs/OnionMessenger.mjs';
644 import { DefaultMessageRouter } from '../structs/DefaultMessageRouter.mjs';
645 import { IntroductionNode } from '../structs/IntroductionNode.mjs';
646 import { EmptyNodeIdLookUp } from '../structs/EmptyNodeIdLookUp.mjs';
647 import { ForwardTlvs } from '../structs/ForwardTlvs.mjs';
648 import { CoinSelectionSource, CoinSelectionSourceInterface } from '../structs/CoinSelectionSource.mjs';
649 import { WalletSource, WalletSourceInterface } from '../structs/WalletSource.mjs';
650 import { Wallet } from '../structs/Wallet.mjs';
651 import { BumpTransactionEventHandler } from '../structs/BumpTransactionEventHandler.mjs';
652 import { RapidGossipSync } from '../structs/RapidGossipSync.mjs';
653 import { GossipSync } from '../structs/GossipSync.mjs';
654 import { RawDataPart } from '../structs/RawDataPart.mjs';
655 import { Sha256 } from '../structs/Sha256.mjs';
656 import { ExpiryTime } from '../structs/ExpiryTime.mjs';
657 import { MinFinalCltvExpiryDelta } from '../structs/MinFinalCltvExpiryDelta.mjs';
658 import { Fallback } from '../structs/Fallback.mjs';
660 import { CommonBase, UInt5, WitnessVersion, UnqualifiedError } from './CommonBase.mjs';
661 import * as bindings from '../bindings.mjs'
665 * A lightning node's channel state machine and payment management logic, which facilitates
666 * sending, forwarding, and receiving payments through lightning channels.
668 * [`ChannelManager`] is parameterized by a number of components to achieve this.
669 * - [`chain::Watch`] (typically [`ChainMonitor`]) for on-chain monitoring and enforcement of each
671 * - [`BroadcasterInterface`] for broadcasting transactions related to opening, funding, and
673 * - [`EntropySource`] for providing random data needed for cryptographic operations
674 * - [`NodeSigner`] for cryptographic operations scoped to the node
675 * - [`SignerProvider`] for providing signers whose operations are scoped to individual channels
676 * - [`FeeEstimator`] to determine transaction fee rates needed to have a transaction mined in a
678 * - [`Router`] for finding payment paths when initiating and retrying payments
679 * - [`Logger`] for logging operational information of varying degrees
681 * Additionally, it implements the following traits:
682 * - [`ChannelMessageHandler`] to handle off-chain channel activity from peers
683 * - [`MessageSendEventsProvider`] to similarly send such messages to peers
684 * - [`OffersMessageHandler`] for BOLT 12 message handling and sending
685 * - [`EventsProvider`] to generate user-actionable [`Event`]s
686 * - [`chain::Listen`] and [`chain::Confirm`] for notification of on-chain activity
688 * Thus, [`ChannelManager`] is typically used to parameterize a [`MessageHandler`] and an
689 * [`OnionMessenger`]. The latter is required to support BOLT 12 functionality.
691 * # `ChannelManager` vs `ChannelMonitor`
693 * It's important to distinguish between the *off-chain* management and *on-chain* enforcement of
694 * lightning channels. [`ChannelManager`] exchanges messages with peers to manage the off-chain
695 * state of each channel. During this process, it generates a [`ChannelMonitor`] for each channel
696 * and a [`ChannelMonitorUpdate`] for each relevant change, notifying its parameterized
697 * [`chain::Watch`] of them.
699 * An implementation of [`chain::Watch`], such as [`ChainMonitor`], is responsible for aggregating
700 * these [`ChannelMonitor`]s and applying any [`ChannelMonitorUpdate`]s to them. It then monitors
701 * for any pertinent on-chain activity, enforcing claims as needed.
703 * This division of off-chain management and on-chain enforcement allows for interesting node
704 * setups. For instance, on-chain enforcement could be moved to a separate host or have added
705 * redundancy, possibly as a watchtower. See [`chain::Watch`] for the relevant interface.
709 * Use [`ChannelManager::new`] with the most recent [`BlockHash`] when creating a fresh instance.
710 * Otherwise, if restarting, construct [`ChannelManagerReadArgs`] with the necessary parameters and
711 * references to any deserialized [`ChannelMonitor`]s that were previously persisted. Use this to
712 * deserialize the [`ChannelManager`] and feed it any new chain data since it was last online, as
713 * detailed in the [`ChannelManagerReadArgs`] documentation.
716 * use bitcoin::BlockHash;
717 * use bitcoin::network::constants::Network;
718 * use lightning::chain::BestBlock;
719 * # use lightning::chain::channelmonitor::ChannelMonitor;
720 * use lightning::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs};
721 * # use lightning::routing::gossip::NetworkGraph;
722 * use lightning::util::config::UserConfig;
723 * use lightning::util::ser::ReadableArgs;
725 * # fn read_channel_monitors() -> Vec<ChannelMonitor<lightning::sign::InMemorySigner>> { vec![] }
728 * # L: lightning::util::logger::Logger,
729 * # ES: lightning::sign::EntropySource,
730 * # S: for <'b> lightning::routing::scoring::LockableScore<'b, ScoreLookUp = SL>,
731 * # SL: lightning::routing::scoring::ScoreLookUp<ScoreParams = SP>,
733 * # R: lightning::io::Read,
735 * # fee_estimator: &dyn lightning::chain::chaininterface::FeeEstimator,
736 * # chain_monitor: &dyn lightning::chain::Watch<lightning::sign::InMemorySigner>,
737 * # tx_broadcaster: &dyn lightning::chain::chaininterface::BroadcasterInterface,
738 * # router: &lightning::routing::router::DefaultRouter<&NetworkGraph<&'a L>, &'a L, &ES, &S, SP, SL>,
740 * # entropy_source: &ES,
741 * # node_signer: &dyn lightning::sign::NodeSigner,
742 * # signer_provider: &lightning::sign::DynSignerProvider,
743 * # best_block: lightning::chain::BestBlock,
744 * # current_timestamp: u32,
746 * # ) -> Result<(), lightning::ln::msgs::DecodeError> {
747 * Fresh start with no channels
748 * let params = ChainParameters {
749 * network: Network::Bitcoin,
752 * let default_config = UserConfig::default();
753 * let channel_manager = ChannelManager::new(
754 * fee_estimator, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer,
755 * signer_provider, default_config, params, current_timestamp
758 * Restart from deserialized data
759 * let mut channel_monitors = read_channel_monitors();
760 * let args = ChannelManagerReadArgs::new(
761 * entropy_source, node_signer, signer_provider, fee_estimator, chain_monitor, tx_broadcaster,
762 * router, logger, default_config, channel_monitors.iter_mut().collect()
764 * let (block_hash, channel_manager) =
765 * <(BlockHash, ChannelManager<_, _, _, _, _, _, _, _>)>::read(&mut reader, args)?;
767 * Update the ChannelManager and ChannelMonitors with the latest chain data
770 * Move the monitors to the ChannelManager's chain::Watch parameter
771 * for monitor in channel_monitors {
772 * chain_monitor.watch_channel(monitor.get_funding_txo().0, monitor);
780 * The following is required for [`ChannelManager`] to function properly:
781 * - Handle messages from peers using its [`ChannelMessageHandler`] implementation (typically
782 * called by [`PeerManager::read_event`] when processing network I/O)
783 * - Send messages to peers obtained via its [`MessageSendEventsProvider`] implementation
784 * (typically initiated when [`PeerManager::process_events`] is called)
785 * - Feed on-chain activity using either its [`chain::Listen`] or [`chain::Confirm`] implementation
786 * as documented by those traits
787 * - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly
789 * - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a
790 * [`Persister`] such as a [`KVStore`] implementation
791 * - Handle [`Event`]s obtained via its [`EventsProvider`] implementation
793 * The [`Future`] returned by [`get_event_or_persistence_needed_future`] is useful in determining
794 * when the last two requirements need to be checked.
796 * The [`lightning-block-sync`] and [`lightning-transaction-sync`] crates provide utilities that
797 * simplify feeding in on-chain activity using the [`chain::Listen`] and [`chain::Confirm`] traits,
798 * respectively. The remaining requirements can be met using the [`lightning-background-processor`]
799 * crate. For languages other than Rust, the availability of similar utilities may vary.
803 * [`ChannelManager`]'s primary function involves managing a channel state. Without channels,
804 * payments can't be sent. Use [`list_channels`] or [`list_usable_channels`] for a snapshot of the
805 * currently open channels.
808 * # use lightning::ln::channelmanager::AChannelManager;
810 * # fn example<T: AChannelManager>(channel_manager: T) {
811 * # let channel_manager = channel_manager.get_cm();
812 * let channels = channel_manager.list_usable_channels();
813 * for details in channels {
814 * println!(\"{:?}\", details);
819 * Each channel is identified using a [`ChannelId`], which will change throughout the channel's
820 * life cycle. Additionally, channels are assigned a `user_channel_id`, which is given in
821 * [`Event`]s associated with the channel and serves as a fixed identifier but is otherwise unused
822 * by [`ChannelManager`].
824 * ## Opening Channels
826 * To an open a channel with a peer, call [`create_channel`]. This will initiate the process of
827 * opening an outbound channel, which requires self-funding when handling
828 * [`Event::FundingGenerationReady`].
831 * # use bitcoin::{ScriptBuf, Transaction};
832 * # use bitcoin::secp256k1::PublicKey;
833 * # use lightning::ln::channelmanager::AChannelManager;
834 * # use lightning::events::{Event, EventsProvider};
837 * # fn create_funding_transaction(
838 * # &self, _amount_sats: u64, _output_script: ScriptBuf
839 * # ) -> Transaction;
842 * # fn example<T: AChannelManager, W: Wallet>(channel_manager: T, wallet: W, peer_id: PublicKey) {
843 * # let channel_manager = channel_manager.get_cm();
844 * let value_sats = 1_000_000;
845 * let push_msats = 10_000_000;
846 * match channel_manager.create_channel(peer_id, value_sats, push_msats, 42, None, None) {
847 * Ok(channel_id) => println!(\"Opening channel {}\", channel_id),
848 * Err(e) => println!(\"Error opening channel: {:?}\", e),
851 * On the event processing thread once the peer has responded
852 * channel_manager.process_pending_events(&|event| match event {
853 * Event::FundingGenerationReady {
854 * temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script,
855 * user_channel_id, ..
857 * assert_eq!(user_channel_id, 42);
858 * let funding_transaction = wallet.create_funding_transaction(
859 * channel_value_satoshis, output_script
861 * match channel_manager.funding_transaction_generated(
862 * &temporary_channel_id, &counterparty_node_id, funding_transaction
864 * Ok(()) => println!(\"Funding channel {}\", temporary_channel_id),
865 * Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e),
868 * Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => {
869 * assert_eq!(user_channel_id, 42);
871 * \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id,
872 * former_temporary_channel_id.unwrap()
875 * Event::ChannelReady { channel_id, user_channel_id, .. } => {
876 * assert_eq!(user_channel_id, 42);
877 * println!(\"Channel {} ready\", channel_id);
885 * ## Accepting Channels
887 * Inbound channels are initiated by peers and are automatically accepted unless [`ChannelManager`]
888 * has [`UserConfig::manually_accept_inbound_channels`] set. In that case, the channel may be
889 * either accepted or rejected when handling [`Event::OpenChannelRequest`].
892 * # use bitcoin::secp256k1::PublicKey;
893 * # use lightning::ln::channelmanager::AChannelManager;
894 * # use lightning::events::{Event, EventsProvider};
896 * # fn is_trusted(counterparty_node_id: PublicKey) -> bool {
901 * # fn example<T: AChannelManager>(channel_manager: T) {
902 * # let channel_manager = channel_manager.get_cm();
903 * channel_manager.process_pending_events(&|event| match event {
904 * Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => {
905 * if !is_trusted(counterparty_node_id) {
906 * match channel_manager.force_close_without_broadcasting_txn(
907 * &temporary_channel_id, &counterparty_node_id
909 * Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id),
910 * Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e),
915 * let user_channel_id = 43;
916 * match channel_manager.accept_inbound_channel(
917 * &temporary_channel_id, &counterparty_node_id, user_channel_id
919 * Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id),
920 * Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e),
929 * ## Closing Channels
931 * There are two ways to close a channel: either cooperatively using [`close_channel`] or
932 * unilaterally using [`force_close_broadcasting_latest_txn`]. The former is ideal as it makes for
933 * lower fees and immediate access to funds. However, the latter may be necessary if the
934 * counterparty isn't behaving properly or has gone offline. [`Event::ChannelClosed`] is generated
935 * once the channel has been closed successfully.
938 * # use bitcoin::secp256k1::PublicKey;
939 * # use lightning::ln::types::ChannelId;
940 * # use lightning::ln::channelmanager::AChannelManager;
941 * # use lightning::events::{Event, EventsProvider};
943 * # fn example<T: AChannelManager>(
944 * # channel_manager: T, channel_id: ChannelId, counterparty_node_id: PublicKey
946 * # let channel_manager = channel_manager.get_cm();
947 * match channel_manager.close_channel(&channel_id, &counterparty_node_id) {
948 * Ok(()) => println!(\"Closing channel {}\", channel_id),
949 * Err(e) => println!(\"Error closing channel {}: {:?}\", channel_id, e),
952 * On the event processing thread
953 * channel_manager.process_pending_events(&|event| match event {
954 * Event::ChannelClosed { channel_id, user_channel_id, .. } => {
955 * assert_eq!(user_channel_id, 42);
956 * println!(\"Channel {} closed\", channel_id);
966 * [`ChannelManager`] is responsible for sending, forwarding, and receiving payments through its
967 * channels. A payment is typically initiated from a [BOLT 11] invoice or a [BOLT 12] offer, though
968 * spontaneous (i.e., keysend) payments are also possible. Incoming payments don't require
969 * maintaining any additional state as [`ChannelManager`] can reconstruct the [`PaymentPreimage`]
970 * from the [`PaymentSecret`]. Sending payments, however, require tracking in order to retry failed
973 * After a payment is initiated, it will appear in [`list_recent_payments`] until a short time
974 * after either an [`Event::PaymentSent`] or [`Event::PaymentFailed`] is handled. Failed HTLCs
975 * for a payment will be retried according to the payment's [`Retry`] strategy or until
976 * [`abandon_payment`] is called.
978 * ## BOLT 11 Invoices
980 * The [`lightning-invoice`] crate is useful for creating BOLT 11 invoices. Specifically, use the
981 * functions in its `utils` module for constructing invoices that are compatible with
982 * [`ChannelManager`]. These functions serve as a convenience for building invoices with the
983 * [`PaymentHash`] and [`PaymentSecret`] returned from [`create_inbound_payment`]. To provide your
984 * own [`PaymentHash`], use [`create_inbound_payment_for_hash`] or the corresponding functions in
985 * the [`lightning-invoice`] `utils` module.
987 * [`ChannelManager`] generates an [`Event::PaymentClaimable`] once the full payment has been
988 * received. Call [`claim_funds`] to release the [`PaymentPreimage`], which in turn will result in
989 * an [`Event::PaymentClaimed`].
992 * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
993 * # use lightning::ln::channelmanager::AChannelManager;
995 * # fn example<T: AChannelManager>(channel_manager: T) {
996 * # let channel_manager = channel_manager.get_cm();
997 * Or use utils::create_invoice_from_channelmanager
998 * let known_payment_hash = match channel_manager.create_inbound_payment(
999 * Some(10_000_000), 3600, None
1001 * Ok((payment_hash, _payment_secret)) => {
1002 * println!(\"Creating inbound payment {}\", payment_hash);
1005 * Err(()) => panic!(\"Error creating inbound payment\"),
1008 * On the event processing thread
1009 * channel_manager.process_pending_events(&|event| match event {
1010 * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
1011 * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => {
1012 * assert_eq!(payment_hash, known_payment_hash);
1013 * println!(\"Claiming payment {}\", payment_hash);
1014 * channel_manager.claim_funds(payment_preimage);
1016 * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => {
1017 * println!(\"Unknown payment hash: {}\", payment_hash);
1019 * PaymentPurpose::SpontaneousPayment(payment_preimage) => {
1020 * assert_ne!(payment_hash, known_payment_hash);
1021 * println!(\"Claiming spontaneous payment {}\", payment_hash);
1022 * channel_manager.claim_funds(payment_preimage);
1027 * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
1028 * assert_eq!(payment_hash, known_payment_hash);
1029 * println!(\"Claimed {} msats\", amount_msat);
1037 * For paying an invoice, [`lightning-invoice`] provides a `payment` module with convenience
1038 * functions for use with [`send_payment`].
1041 * # use lightning::events::{Event, EventsProvider};
1042 * # use lightning::ln::types::PaymentHash;
1043 * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, RecipientOnionFields, Retry};
1044 * # use lightning::routing::router::RouteParameters;
1046 * # fn example<T: AChannelManager>(
1047 * # channel_manager: T, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
1048 * # route_params: RouteParameters, retry: Retry
1050 * # let channel_manager = channel_manager.get_cm();
1051 * let (payment_hash, recipient_onion, route_params) =
1052 * payment::payment_parameters_from_invoice(&invoice);
1053 * let payment_id = PaymentId([42; 32]);
1054 * match channel_manager.send_payment(
1055 * payment_hash, recipient_onion, payment_id, route_params, retry
1057 * Ok(()) => println!(\"Sending payment with hash {}\", payment_hash),
1058 * Err(e) => println!(\"Failed sending payment with hash {}: {:?}\", payment_hash, e),
1061 * let expected_payment_id = payment_id;
1062 * let expected_payment_hash = payment_hash;
1064 * channel_manager.list_recent_payments().iter().find(|details| matches!(
1066 * RecentPaymentDetails::Pending {
1067 * payment_id: expected_payment_id,
1068 * payment_hash: expected_payment_hash,
1074 * On the event processing thread
1075 * channel_manager.process_pending_events(&|event| match event {
1076 * Event::PaymentSent { payment_hash, .. } => println!(\"Paid {}\", payment_hash),
1077 * Event::PaymentFailed { payment_hash, .. } => println!(\"Failed paying {}\", payment_hash),
1086 * The [`offers`] module is useful for creating BOLT 12 offers. An [`Offer`] is a precursor to a
1087 * [`Bolt12Invoice`], which must first be requested by the payer. The interchange of these messages
1088 * as defined in the specification is handled by [`ChannelManager`] and its implementation of
1089 * [`OffersMessageHandler`]. However, this only works with an [`Offer`] created using a builder
1090 * returned by [`create_offer_builder`]. With this approach, BOLT 12 offers and invoices are
1091 * stateless just as BOLT 11 invoices are.
1094 * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
1095 * # use lightning::ln::channelmanager::AChannelManager;
1096 * # use lightning::offers::parse::Bolt12SemanticError;
1098 * # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> {
1099 * # let channel_manager = channel_manager.get_cm();
1100 * let offer = channel_manager
1101 * .create_offer_builder()?
1103 * # // Needed for compiling for c_bindings
1104 * # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into();
1105 * # let offer = builder
1106 * .description(\"coffee\".to_string())
1107 * .amount_msats(10_000_000)
1109 * let bech32_offer = offer.to_string();
1111 * On the event processing thread
1112 * channel_manager.process_pending_events(&|event| match event {
1113 * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
1114 * PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => {
1115 * println!(\"Claiming payment {}\", payment_hash);
1116 * channel_manager.claim_funds(payment_preimage);
1118 * PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => {
1119 * println!(\"Unknown payment hash: {}\", payment_hash);
1124 * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
1125 * println!(\"Claimed {} msats\", amount_msat);
1134 * Use [`pay_for_offer`] to initiated payment, which sends an [`InvoiceRequest`] for an [`Offer`]
1135 * and pays the [`Bolt12Invoice`] response. In addition to success and failure events,
1136 * [`ChannelManager`] may also generate an [`Event::InvoiceRequestFailed`].
1139 * # use lightning::events::{Event, EventsProvider};
1140 * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
1141 * # use lightning::offers::offer::Offer;
1143 * # fn example<T: AChannelManager>(
1144 * # channel_manager: T, offer: &Offer, quantity: Option<u64>, amount_msats: Option<u64>,
1145 * # payer_note: Option<String>, retry: Retry, max_total_routing_fee_msat: Option<u64>
1147 * # let channel_manager = channel_manager.get_cm();
1148 * let payment_id = PaymentId([42; 32]);
1149 * match channel_manager.pay_for_offer(
1150 * offer, quantity, amount_msats, payer_note, payment_id, retry, max_total_routing_fee_msat
1152 * Ok(()) => println!(\"Requesting invoice for offer\"),
1153 * Err(e) => println!(\"Unable to request invoice for offer: {:?}\", e),
1156 * First the payment will be waiting on an invoice
1157 * let expected_payment_id = payment_id;
1159 * channel_manager.list_recent_payments().iter().find(|details| matches!(
1161 * RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id }
1165 * Once the invoice is received, a payment will be sent
1167 * channel_manager.list_recent_payments().iter().find(|details| matches!(
1169 * RecentPaymentDetails::Pending { payment_id: expected_payment_id, .. }
1173 * On the event processing thread
1174 * channel_manager.process_pending_events(&|event| match event {
1175 * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id),
1176 * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
1177 * Event::InvoiceRequestFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
1184 * ## BOLT 12 Refunds
1186 * A [`Refund`] is a request for an invoice to be paid. Like *paying* for an [`Offer`], *creating*
1187 * a [`Refund`] involves maintaining state since it represents a future outbound payment.
1188 * Therefore, use [`create_refund_builder`] when creating one, otherwise [`ChannelManager`] will
1189 * refuse to pay any corresponding [`Bolt12Invoice`] that it receives.
1192 * # use core::time::Duration;
1193 * # use lightning::events::{Event, EventsProvider};
1194 * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
1195 * # use lightning::offers::parse::Bolt12SemanticError;
1197 * # fn example<T: AChannelManager>(
1198 * # channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry,
1199 * # max_total_routing_fee_msat: Option<u64>
1200 * # ) -> Result<(), Bolt12SemanticError> {
1201 * # let channel_manager = channel_manager.get_cm();
1202 * let payment_id = PaymentId([42; 32]);
1203 * let refund = channel_manager
1204 * .create_refund_builder(
1205 * amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
1208 * # // Needed for compiling for c_bindings
1209 * # let builder: lightning::offers::refund::RefundBuilder<_> = refund.into();
1210 * # let refund = builder
1211 * .description(\"coffee\".to_string())
1212 * .payer_note(\"refund for order 1234\".to_string())
1214 * let bech32_refund = refund.to_string();
1216 * First the payment will be waiting on an invoice
1217 * let expected_payment_id = payment_id;
1219 * channel_manager.list_recent_payments().iter().find(|details| matches!(
1221 * RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id }
1225 * Once the invoice is received, a payment will be sent
1227 * channel_manager.list_recent_payments().iter().find(|details| matches!(
1229 * RecentPaymentDetails::Pending { payment_id: expected_payment_id, .. }
1233 * On the event processing thread
1234 * channel_manager.process_pending_events(&|event| match event {
1235 * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id),
1236 * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
1244 * Use [`request_refund_payment`] to send a [`Bolt12Invoice`] for receiving the refund. Similar to
1245 * creating* an [`Offer`], this is stateless as it represents an inbound payment.
1248 * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
1249 * # use lightning::ln::channelmanager::AChannelManager;
1250 * # use lightning::offers::refund::Refund;
1252 * # fn example<T: AChannelManager>(channel_manager: T, refund: &Refund) {
1253 * # let channel_manager = channel_manager.get_cm();
1254 * let known_payment_hash = match channel_manager.request_refund_payment(refund) {
1256 * let payment_hash = invoice.payment_hash();
1257 * println!(\"Requesting refund payment {}\", payment_hash);
1260 * Err(e) => panic!(\"Unable to request payment for refund: {:?}\", e),
1263 * On the event processing thread
1264 * channel_manager.process_pending_events(&|event| match event {
1265 * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
1266 * \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => {
1267 * assert_eq!(payment_hash, known_payment_hash);
1268 * println!(\"Claiming payment {}\", payment_hash);
1269 * channel_manager.claim_funds(payment_preimage);
1271 * \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => {
1272 * println!(\"Unknown payment hash: {}\", payment_hash);
1277 * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
1278 * assert_eq!(payment_hash, known_payment_hash);
1279 * println!(\"Claimed {} msats\", amount_msat);
1289 * Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
1290 * all peers during write/read (though does not modify this instance, only the instance being
1291 * serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e.,
1292 * called [`funding_transaction_generated`] for outbound channels) being closed.
1294 * Note that you can be a bit lazier about writing out `ChannelManager` than you can be with
1295 * [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST durably write each
1296 * [`ChannelMonitorUpdate`] before returning from
1297 * [`chain::Watch::watch_channel`]/[`update_channel`] or before completing async writes. With
1298 * `ChannelManager`s, writing updates happens out-of-band (and will prevent any other
1299 * `ChannelManager` operations from occurring during the serialization process). If the
1300 * deserialized version is out-of-date compared to the [`ChannelMonitor`] passed by reference to
1301 * [`read`], those channels will be force-closed based on the `ChannelMonitor` state and no funds
1302 * will be lost (modulo on-chain transaction fees).
1304 * Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which
1305 * tells you the last block hash which was connected. You should get the best block tip before using the manager.
1306 * See [`chain::Listen`] and [`chain::Confirm`] for more details.
1308 * # `ChannelUpdate` Messages
1310 * Note that `ChannelManager` is responsible for tracking liveness of its channels and generating
1311 * [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid
1312 * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
1313 * offline for a full minute. In order to track this, you must call
1314 * [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect.
1318 * To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and
1319 * inbound channels without confirmed funding transactions. This may result in nodes which we do
1320 * not have a channel with being unable to connect to us or open new channels with us if we have
1321 * many peers with unfunded channels.
1323 * Because it is an indication of trust, inbound channels which we've accepted as 0conf are
1324 * exempted from the count of unfunded channels. Similarly, outbound channels and connections are
1325 * never limited. Please ensure you limit the count of such channels yourself.
1329 * Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`]
1330 * a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but
1331 * essentially you should default to using a [`SimpleRefChannelManager`], and use a
1332 * [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when
1333 * you're using lightning-net-tokio.
1335 * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
1336 * [`MessageHandler`]: crate::ln::peer_handler::MessageHandler
1337 * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
1338 * [`PeerManager::read_event`]: crate::ln::peer_handler::PeerManager::read_event
1339 * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
1340 * [`timer_tick_occurred`]: Self::timer_tick_occurred
1341 * [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence
1342 * [`Persister`]: crate::util::persist::Persister
1343 * [`KVStore`]: crate::util::persist::KVStore
1344 * [`get_event_or_persistence_needed_future`]: Self::get_event_or_persistence_needed_future
1345 * [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync
1346 * [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync
1347 * [`lightning-background-processor`]: https://docs.rs/lightning_background_processor/lightning_background_processor
1348 * [`list_channels`]: Self::list_channels
1349 * [`list_usable_channels`]: Self::list_usable_channels
1350 * [`create_channel`]: Self::create_channel
1351 * [`close_channel`]: Self::force_close_broadcasting_latest_txn
1352 * [`force_close_broadcasting_latest_txn`]: Self::force_close_broadcasting_latest_txn
1353 * [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
1354 * [BOLT 12]: https://github.com/rustyrussell/lightning-rfc/blob/guilt/offers/12-offer-encoding.md
1355 * [`list_recent_payments`]: Self::list_recent_payments
1356 * [`abandon_payment`]: Self::abandon_payment
1357 * [`lightning-invoice`]: https://docs.rs/lightning_invoice/latest/lightning_invoice
1358 * [`create_inbound_payment`]: Self::create_inbound_payment
1359 * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
1360 * [`claim_funds`]: Self::claim_funds
1361 * [`send_payment`]: Self::send_payment
1362 * [`offers`]: crate::offers
1363 * [`create_offer_builder`]: Self::create_offer_builder
1364 * [`pay_for_offer`]: Self::pay_for_offer
1365 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
1366 * [`create_refund_builder`]: Self::create_refund_builder
1367 * [`request_refund_payment`]: Self::request_refund_payment
1368 * [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
1369 * [`funding_created`]: msgs::FundingCreated
1370 * [`funding_transaction_generated`]: Self::funding_transaction_generated
1371 * [`BlockHash`]: bitcoin::hash_types::BlockHash
1372 * [`update_channel`]: chain::Watch::update_channel
1373 * [`ChannelUpdate`]: msgs::ChannelUpdate
1374 * [`read`]: ReadableArgs::read
1376 export class ChannelManager extends CommonBase {
1378 public constructor(_dummy: null, ptr: bigint) {
1379 super(ptr, bindings.ChannelManager_free);
1383 * Constructs a new `ChannelManager` to hold several channels and route between them.
1385 * The current time or latest block header time can be provided as the `current_timestamp`.
1387 * This is the main \"logic hub\" for all channel-related actions, and implements
1388 * [`ChannelMessageHandler`].
1390 * Non-proportional fees are fixed according to our risk using the provided fee estimator.
1392 * Users need to notify the new `ChannelManager` when a new block is connected or
1393 * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting
1394 * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for
1397 * [`block_connected`]: chain::Listen::block_connected
1398 * [`block_disconnected`]: chain::Listen::block_disconnected
1399 * [`params.best_block.block_hash`]: chain::BestBlock::block_hash
1401 public static constructor_new(fee_est: FeeEstimator, chain_monitor: Watch, tx_broadcaster: BroadcasterInterface, router: Router, logger: Logger, entropy_source: EntropySource, node_signer: NodeSigner, signer_provider: SignerProvider, config: UserConfig, params: ChainParameters, current_timestamp: number): ChannelManager {
1402 const ret: bigint = bindings.ChannelManager_new(CommonBase.get_ptr_of(fee_est), CommonBase.get_ptr_of(chain_monitor), CommonBase.get_ptr_of(tx_broadcaster), CommonBase.get_ptr_of(router), CommonBase.get_ptr_of(logger), CommonBase.get_ptr_of(entropy_source), CommonBase.get_ptr_of(node_signer), CommonBase.get_ptr_of(signer_provider), CommonBase.get_ptr_of(config), CommonBase.get_ptr_of(params), current_timestamp);
1403 const ret_hu_conv: ChannelManager = new ChannelManager(null, ret);
1404 CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
1405 CommonBase.add_ref_from(ret_hu_conv, fee_est);
1406 CommonBase.add_ref_from(ret_hu_conv, chain_monitor);
1407 CommonBase.add_ref_from(ret_hu_conv, tx_broadcaster);
1408 CommonBase.add_ref_from(ret_hu_conv, router);
1409 CommonBase.add_ref_from(ret_hu_conv, logger);
1410 CommonBase.add_ref_from(ret_hu_conv, entropy_source);
1411 CommonBase.add_ref_from(ret_hu_conv, node_signer);
1412 CommonBase.add_ref_from(ret_hu_conv, signer_provider);
1413 CommonBase.add_ref_from(ret_hu_conv, config);
1414 CommonBase.add_ref_from(ret_hu_conv, params);
1419 * Gets the current configuration applied to all new channels.
1421 public get_current_default_configuration(): UserConfig {
1422 const ret: bigint = bindings.ChannelManager_get_current_default_configuration(this.ptr);
1423 const ret_hu_conv: UserConfig = new UserConfig(null, ret);
1424 CommonBase.add_ref_from(ret_hu_conv, this);
1429 * Creates a new outbound channel to the given remote node and with the given value.
1431 * `user_channel_id` will be provided back as in
1432 * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
1433 * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a
1434 * randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it
1435 * is simply copied to events and otherwise ignored.
1437 * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
1438 * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
1440 * Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to
1441 * generate a shutdown scriptpubkey or destination script set by
1442 * [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`].
1444 * Note that we do not check if you are currently connected to the given peer. If no
1445 * connection is available, the outbound `open_channel` message may fail to send, resulting in
1446 * the channel eventually being silently forgotten (dropped on reload).
1448 * If `temporary_channel_id` is specified, it will be used as the temporary channel ID of the
1449 * channel. Otherwise, a random one will be generated for you.
1451 * Returns the new Channel's temporary `channel_id`. This ID will appear as
1452 * [`Event::FundingGenerationReady::temporary_channel_id`] and in
1453 * [`ChannelDetails::channel_id`] until after
1454 * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
1455 * one derived from the funding transaction's TXID. If the counterparty rejects the channel
1456 * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
1458 * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
1459 * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
1460 * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
1462 * Note that temporary_channel_id (or a relevant inner pointer) may be NULL or all-0s to represent None
1463 * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
1465 public create_channel(their_network_key: Uint8Array, channel_value_satoshis: bigint, push_msat: bigint, user_channel_id: bigint, temporary_channel_id: ChannelId|null, override_config: UserConfig|null): Result_ChannelIdAPIErrorZ {
1466 const ret: bigint = bindings.ChannelManager_create_channel(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(their_network_key, 33)), channel_value_satoshis, push_msat, bindings.encodeUint128(user_channel_id), temporary_channel_id == null ? 0n : CommonBase.get_ptr_of(temporary_channel_id), override_config == null ? 0n : CommonBase.get_ptr_of(override_config));
1467 const ret_hu_conv: Result_ChannelIdAPIErrorZ = Result_ChannelIdAPIErrorZ.constr_from_ptr(ret);
1468 CommonBase.add_ref_from(this, temporary_channel_id);
1469 CommonBase.add_ref_from(this, override_config);
1474 * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for
1477 public list_channels(): ChannelDetails[] {
1478 const ret: number = bindings.ChannelManager_list_channels(this.ptr);
1479 const ret_conv_16_len: number = bindings.getArrayLength(ret);
1480 const ret_conv_16_arr: ChannelDetails[] = new Array(ret_conv_16_len).fill(null);
1481 for (var q = 0; q < ret_conv_16_len; q++) {
1482 const ret_conv_16: bigint = bindings.getU64ArrayElem(ret, q);
1483 const ret_conv_16_hu_conv: ChannelDetails = new ChannelDetails(null, ret_conv_16);
1484 CommonBase.add_ref_from(ret_conv_16_hu_conv, this);
1485 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
1487 bindings.freeWasmMemory(ret)
1488 return ret_conv_16_arr;
1492 * Gets the list of usable channels, in random order. Useful as an argument to
1493 * [`Router::find_route`] to ensure non-announced channels are used.
1495 * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
1496 * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
1499 public list_usable_channels(): ChannelDetails[] {
1500 const ret: number = bindings.ChannelManager_list_usable_channels(this.ptr);
1501 const ret_conv_16_len: number = bindings.getArrayLength(ret);
1502 const ret_conv_16_arr: ChannelDetails[] = new Array(ret_conv_16_len).fill(null);
1503 for (var q = 0; q < ret_conv_16_len; q++) {
1504 const ret_conv_16: bigint = bindings.getU64ArrayElem(ret, q);
1505 const ret_conv_16_hu_conv: ChannelDetails = new ChannelDetails(null, ret_conv_16);
1506 CommonBase.add_ref_from(ret_conv_16_hu_conv, this);
1507 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
1509 bindings.freeWasmMemory(ret)
1510 return ret_conv_16_arr;
1514 * Gets the list of channels we have with a given counterparty, in random order.
1516 public list_channels_with_counterparty(counterparty_node_id: Uint8Array): ChannelDetails[] {
1517 const ret: number = bindings.ChannelManager_list_channels_with_counterparty(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)));
1518 const ret_conv_16_len: number = bindings.getArrayLength(ret);
1519 const ret_conv_16_arr: ChannelDetails[] = new Array(ret_conv_16_len).fill(null);
1520 for (var q = 0; q < ret_conv_16_len; q++) {
1521 const ret_conv_16: bigint = bindings.getU64ArrayElem(ret, q);
1522 const ret_conv_16_hu_conv: ChannelDetails = new ChannelDetails(null, ret_conv_16);
1523 CommonBase.add_ref_from(ret_conv_16_hu_conv, this);
1524 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
1526 bindings.freeWasmMemory(ret)
1527 return ret_conv_16_arr;
1531 * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a
1532 * successful path, or have unresolved HTLCs.
1534 * This can be useful for payments that may have been prepared, but ultimately not sent, as a
1535 * result of a crash. If such a payment exists, is not listed here, and an
1536 * [`Event::PaymentSent`] has not been received, you may consider resending the payment.
1538 * [`Event::PaymentSent`]: events::Event::PaymentSent
1540 public list_recent_payments(): RecentPaymentDetails[] {
1541 const ret: number = bindings.ChannelManager_list_recent_payments(this.ptr);
1542 const ret_conv_22_len: number = bindings.getArrayLength(ret);
1543 const ret_conv_22_arr: RecentPaymentDetails[] = new Array(ret_conv_22_len).fill(null);
1544 for (var w = 0; w < ret_conv_22_len; w++) {
1545 const ret_conv_22: bigint = bindings.getU64ArrayElem(ret, w);
1546 const ret_conv_22_hu_conv: RecentPaymentDetails = RecentPaymentDetails.constr_from_ptr(ret_conv_22);
1547 CommonBase.add_ref_from(ret_conv_22_hu_conv, this);
1548 ret_conv_22_arr[w] = ret_conv_22_hu_conv;
1550 bindings.freeWasmMemory(ret)
1551 return ret_conv_22_arr;
1555 * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
1556 * will be accepted on the given channel, and after additional timeout/the closing of all
1557 * pending HTLCs, the channel will be closed on chain.
1559 * If we are the channel initiator, we will pay between our [`ChannelCloseMinimum`] and
1560 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
1562 * If our counterparty is the channel initiator, we will require a channel closing
1563 * transaction feerate of at least our [`ChannelCloseMinimum`] feerate or the feerate which
1564 * would appear on a force-closure transaction, whichever is lower. We will allow our
1565 * counterparty to pay as much fee as they'd like, however.
1567 * May generate a [`SendShutdown`] message event on success, which should be relayed.
1569 * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
1570 * generate a shutdown scriptpubkey or destination script set by
1571 * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
1574 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
1575 * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
1576 * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
1577 * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
1579 public close_channel(channel_id: ChannelId, counterparty_node_id: Uint8Array): Result_NoneAPIErrorZ {
1580 const ret: bigint = bindings.ChannelManager_close_channel(this.ptr, CommonBase.get_ptr_of(channel_id), bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)));
1581 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1582 CommonBase.add_ref_from(this, channel_id);
1587 * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
1588 * will be accepted on the given channel, and after additional timeout/the closing of all
1589 * pending HTLCs, the channel will be closed on chain.
1591 * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
1592 * the channel being closed or not:
1593 * If we are the channel initiator, we will pay at least this feerate on the closing
1594 * transaction. The upper-bound is set by
1595 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
1596 * fee estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
1597 * If our counterparty is the channel initiator, we will refuse to accept a channel closure
1598 * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
1599 * will appear on a force-closure transaction, whichever is lower).
1601 * The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction.
1602 * Will fail if a shutdown script has already been set for this channel by
1603 * ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must
1604 * also be compatible with our and the counterparty's features.
1606 * May generate a [`SendShutdown`] message event on success, which should be relayed.
1608 * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
1609 * generate a shutdown scriptpubkey or destination script set by
1610 * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
1613 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
1614 * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
1615 * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
1617 * Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None
1619 public close_channel_with_feerate_and_script(channel_id: ChannelId, counterparty_node_id: Uint8Array, target_feerate_sats_per_1000_weight: Option_u32Z, shutdown_script: ShutdownScript|null): Result_NoneAPIErrorZ {
1620 const ret: bigint = bindings.ChannelManager_close_channel_with_feerate_and_script(this.ptr, CommonBase.get_ptr_of(channel_id), bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)), CommonBase.get_ptr_of(target_feerate_sats_per_1000_weight), shutdown_script == null ? 0n : CommonBase.get_ptr_of(shutdown_script));
1621 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1622 CommonBase.add_ref_from(this, channel_id);
1623 CommonBase.add_ref_from(this, target_feerate_sats_per_1000_weight);
1624 CommonBase.add_ref_from(this, shutdown_script);
1629 * Force closes a channel, immediately broadcasting the latest local transaction(s) and
1630 * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
1631 * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
1634 public force_close_broadcasting_latest_txn(channel_id: ChannelId, counterparty_node_id: Uint8Array): Result_NoneAPIErrorZ {
1635 const ret: bigint = bindings.ChannelManager_force_close_broadcasting_latest_txn(this.ptr, CommonBase.get_ptr_of(channel_id), bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)));
1636 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1637 CommonBase.add_ref_from(this, channel_id);
1642 * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
1643 * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
1644 * `counterparty_node_id` isn't the counterparty of the corresponding channel.
1646 * You can always broadcast the latest local transaction(s) via
1647 * [`ChannelMonitor::broadcast_latest_holder_commitment_txn`].
1649 public force_close_without_broadcasting_txn(channel_id: ChannelId, counterparty_node_id: Uint8Array): Result_NoneAPIErrorZ {
1650 const ret: bigint = bindings.ChannelManager_force_close_without_broadcasting_txn(this.ptr, CommonBase.get_ptr_of(channel_id), bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)));
1651 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1652 CommonBase.add_ref_from(this, channel_id);
1657 * Force close all channels, immediately broadcasting the latest local commitment transaction
1658 * for each to the chain and rejecting new HTLCs on each.
1660 public force_close_all_channels_broadcasting_latest_txn(): void {
1661 bindings.ChannelManager_force_close_all_channels_broadcasting_latest_txn(this.ptr);
1665 * Force close all channels rejecting new HTLCs on each but without broadcasting the latest
1666 * local transaction(s).
1668 public force_close_all_channels_without_broadcasting_txn(): void {
1669 bindings.ChannelManager_force_close_all_channels_without_broadcasting_txn(this.ptr);
1673 * Sends a payment along a given route.
1675 * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
1676 * fields for more info.
1678 * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
1679 * [`PeerManager::process_events`]).
1681 * # Avoiding Duplicate Payments
1683 * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
1684 * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
1685 * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
1686 * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
1687 * second payment with the same [`PaymentId`].
1689 * Thus, in order to ensure duplicate payments are not sent, you should implement your own
1690 * tracking of payments, including state to indicate once a payment has completed. Because you
1691 * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
1692 * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
1693 * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
1695 * Additionally, in the scenario where we begin the process of sending a payment, but crash
1696 * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're
1697 * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
1698 * [`ChannelManager::list_recent_payments`] for more information.
1700 * # Possible Error States on [`PaymentSendFailure`]
1702 * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
1703 * each entry matching the corresponding-index entry in the route paths, see
1704 * [`PaymentSendFailure`] for more info.
1706 * In general, a path may raise:
1707 * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
1708 * node public key) is specified.
1709 * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
1710 * closed, doesn't exist, or the peer is currently disconnected.
1711 * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
1714 * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
1715 * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
1716 * different route unless you intend to pay twice!
1718 * [`RouteHop`]: crate::routing::router::RouteHop
1719 * [`Event::PaymentSent`]: events::Event::PaymentSent
1720 * [`Event::PaymentFailed`]: events::Event::PaymentFailed
1721 * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
1722 * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
1723 * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
1725 public send_payment_with_route(route: Route, payment_hash: Uint8Array, recipient_onion: RecipientOnionFields, payment_id: Uint8Array): Result_NonePaymentSendFailureZ {
1726 const ret: bigint = bindings.ChannelManager_send_payment_with_route(this.ptr, CommonBase.get_ptr_of(route), bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), CommonBase.get_ptr_of(recipient_onion), bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)));
1727 const ret_hu_conv: Result_NonePaymentSendFailureZ = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
1728 CommonBase.add_ref_from(this, route);
1729 CommonBase.add_ref_from(this, recipient_onion);
1734 * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on
1735 * `route_params` and retry failed payment paths based on `retry_strategy`.
1737 public send_payment(payment_hash: Uint8Array, recipient_onion: RecipientOnionFields, payment_id: Uint8Array, route_params: RouteParameters, retry_strategy: Retry): Result_NoneRetryableSendFailureZ {
1738 const ret: bigint = bindings.ChannelManager_send_payment(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), CommonBase.get_ptr_of(recipient_onion), bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)), CommonBase.get_ptr_of(route_params), CommonBase.get_ptr_of(retry_strategy));
1739 const ret_hu_conv: Result_NoneRetryableSendFailureZ = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret);
1740 CommonBase.add_ref_from(this, recipient_onion);
1741 CommonBase.add_ref_from(this, route_params);
1742 CommonBase.add_ref_from(this, retry_strategy);
1747 * Signals that no further attempts for the given payment should occur. Useful if you have a
1748 * pending outbound payment with retries remaining, but wish to stop retrying the payment before
1749 * retries are exhausted.
1751 * # Event Generation
1753 * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
1754 * as there are no remaining pending HTLCs for this payment.
1756 * Note that calling this method does *not* prevent a payment from succeeding. You must still
1757 * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
1758 * determine the ultimate status of a payment.
1760 * # Requested Invoices
1762 * In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning
1763 * the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`]
1764 * and prevent any attempts at paying it once received. The other events may only be generated
1765 * once the invoice has been received.
1767 * # Restart Behavior
1769 * If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
1770 * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
1771 * [`Event::InvoiceRequestFailed`].
1773 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1775 public abandon_payment(payment_id: Uint8Array): void {
1776 bindings.ChannelManager_abandon_payment(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)));
1780 * Send a spontaneous payment, which is a payment that does not require the recipient to have
1781 * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
1782 * the preimage, it must be a cryptographically secure random value that no intermediate node
1783 * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
1784 * never reach the recipient.
1786 * See [`send_payment`] documentation for more details on the return value of this function
1787 * and idempotency guarantees provided by the [`PaymentId`] key.
1789 * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
1790 * [`send_payment`] for more information about the risks of duplicate preimage usage.
1792 * [`send_payment`]: Self::send_payment
1794 public send_spontaneous_payment(route: Route, payment_preimage: Option_ThirtyTwoBytesZ, recipient_onion: RecipientOnionFields, payment_id: Uint8Array): Result_ThirtyTwoBytesPaymentSendFailureZ {
1795 const ret: bigint = bindings.ChannelManager_send_spontaneous_payment(this.ptr, CommonBase.get_ptr_of(route), CommonBase.get_ptr_of(payment_preimage), CommonBase.get_ptr_of(recipient_onion), bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)));
1796 const ret_hu_conv: Result_ThirtyTwoBytesPaymentSendFailureZ = Result_ThirtyTwoBytesPaymentSendFailureZ.constr_from_ptr(ret);
1797 CommonBase.add_ref_from(this, route);
1798 CommonBase.add_ref_from(this, payment_preimage);
1799 CommonBase.add_ref_from(this, recipient_onion);
1804 * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
1805 * based on `route_params` and retry failed payment paths based on `retry_strategy`.
1807 * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous
1810 * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
1812 public send_spontaneous_payment_with_retry(payment_preimage: Option_ThirtyTwoBytesZ, recipient_onion: RecipientOnionFields, payment_id: Uint8Array, route_params: RouteParameters, retry_strategy: Retry): Result_ThirtyTwoBytesRetryableSendFailureZ {
1813 const ret: bigint = bindings.ChannelManager_send_spontaneous_payment_with_retry(this.ptr, CommonBase.get_ptr_of(payment_preimage), CommonBase.get_ptr_of(recipient_onion), bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)), CommonBase.get_ptr_of(route_params), CommonBase.get_ptr_of(retry_strategy));
1814 const ret_hu_conv: Result_ThirtyTwoBytesRetryableSendFailureZ = Result_ThirtyTwoBytesRetryableSendFailureZ.constr_from_ptr(ret);
1815 CommonBase.add_ref_from(this, payment_preimage);
1816 CommonBase.add_ref_from(this, recipient_onion);
1817 CommonBase.add_ref_from(this, route_params);
1818 CommonBase.add_ref_from(this, retry_strategy);
1823 * Send a payment that is probing the given route for liquidity. We calculate the
1824 * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
1825 * us to easily discern them from real payments.
1827 public send_probe(path: Path): Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ {
1828 const ret: bigint = bindings.ChannelManager_send_probe(this.ptr, CommonBase.get_ptr_of(path));
1829 const ret_hu_conv: Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ.constr_from_ptr(ret);
1830 CommonBase.add_ref_from(this, path);
1835 * Sends payment probes over all paths of a route that would be used to pay the given
1836 * amount to the given `node_id`.
1838 * See [`ChannelManager::send_preflight_probes`] for more information.
1840 public send_spontaneous_preflight_probes(node_id: Uint8Array, amount_msat: bigint, final_cltv_expiry_delta: number, liquidity_limit_multiplier: Option_u64Z): Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ {
1841 const ret: bigint = bindings.ChannelManager_send_spontaneous_preflight_probes(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(node_id, 33)), amount_msat, final_cltv_expiry_delta, CommonBase.get_ptr_of(liquidity_limit_multiplier));
1842 const ret_hu_conv: Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
1843 CommonBase.add_ref_from(this, liquidity_limit_multiplier);
1848 * Sends payment probes over all paths of a route that would be used to pay a route found
1849 * according to the given [`RouteParameters`].
1851 * This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting
1852 * the actual payment. Note this is only useful if there likely is sufficient time for the
1853 * probe to settle before sending out the actual payment, e.g., when waiting for user
1854 * confirmation in a wallet UI.
1856 * Otherwise, there is a chance the probe could take up some liquidity needed to complete the
1857 * actual payment. Users should therefore be cautious and might avoid sending probes if
1858 * liquidity is scarce and/or they don't expect the probe to return before they send the
1859 * payment. To mitigate this issue, channels with available liquidity less than the required
1860 * amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight
1861 * probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`.
1863 public send_preflight_probes(route_params: RouteParameters, liquidity_limit_multiplier: Option_u64Z): Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ {
1864 const ret: bigint = bindings.ChannelManager_send_preflight_probes(this.ptr, CommonBase.get_ptr_of(route_params), CommonBase.get_ptr_of(liquidity_limit_multiplier));
1865 const ret_hu_conv: Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
1866 CommonBase.add_ref_from(this, route_params);
1867 CommonBase.add_ref_from(this, liquidity_limit_multiplier);
1872 * Call this upon creation of a funding transaction for the given channel.
1874 * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
1875 * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
1877 * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
1878 * across the p2p network.
1880 * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
1881 * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
1883 * May panic if the output found in the funding transaction is duplicative with some other
1884 * channel (note that this should be trivially prevented by using unique funding transaction
1885 * keys per-channel).
1887 * Do NOT broadcast the funding transaction yourself. When we have safely received our
1888 * counterparty's signature the funding transaction will automatically be broadcast via the
1889 * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
1891 * Note that this includes RBF or similar transaction replacement strategies - lightning does
1892 * not currently support replacing a funding transaction on an existing channel. Instead,
1893 * create a new channel with a conflicting funding transaction.
1895 * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
1896 * the wallet software generating the funding transaction to apply anti-fee sniping as
1897 * implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
1900 * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady
1901 * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed
1903 public funding_transaction_generated(temporary_channel_id: ChannelId, counterparty_node_id: Uint8Array, funding_transaction: Uint8Array): Result_NoneAPIErrorZ {
1904 const ret: bigint = bindings.ChannelManager_funding_transaction_generated(this.ptr, CommonBase.get_ptr_of(temporary_channel_id), bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)), bindings.encodeUint8Array(funding_transaction));
1905 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1906 CommonBase.add_ref_from(this, temporary_channel_id);
1911 * Call this upon creation of a batch funding transaction for the given channels.
1913 * Return values are identical to [`Self::funding_transaction_generated`], respective to
1914 * each individual channel and transaction output.
1916 * Do NOT broadcast the funding transaction yourself. This batch funding transaction
1917 * will only be broadcast when we have safely received and persisted the counterparty's
1918 * signature for each channel.
1920 * If there is an error, all channels in the batch are to be considered closed.
1922 public batch_funding_transaction_generated(temporary_channels: TwoTuple_ChannelIdPublicKeyZ[], funding_transaction: Uint8Array): Result_NoneAPIErrorZ {
1923 const ret: bigint = bindings.ChannelManager_batch_funding_transaction_generated(this.ptr, bindings.encodeUint64Array(temporary_channels.map(temporary_channels_conv_30 => CommonBase.get_ptr_of(temporary_channels_conv_30))), bindings.encodeUint8Array(funding_transaction));
1924 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1929 * Atomically applies partial updates to the [`ChannelConfig`] of the given channels.
1931 * Once the updates are applied, each eligible channel (advertised with a known short channel
1932 * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
1933 * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
1934 * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
1936 * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
1937 * `counterparty_node_id` is provided.
1939 * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
1940 * below [`MIN_CLTV_EXPIRY_DELTA`].
1942 * If an error is returned, none of the updates should be considered applied.
1944 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
1945 * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
1946 * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
1947 * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
1948 * [`ChannelUpdate`]: msgs::ChannelUpdate
1949 * [`ChannelUnavailable`]: APIError::ChannelUnavailable
1950 * [`APIMisuseError`]: APIError::APIMisuseError
1952 public update_partial_channel_config(counterparty_node_id: Uint8Array, channel_ids: ChannelId[], config_update: ChannelConfigUpdate): Result_NoneAPIErrorZ {
1953 const ret: bigint = bindings.ChannelManager_update_partial_channel_config(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)), bindings.encodeUint64Array(channel_ids.map(channel_ids_conv_11 => CommonBase.get_ptr_of(channel_ids_conv_11))), CommonBase.get_ptr_of(config_update));
1954 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1955 channel_ids.forEach((channel_ids_conv_11: ChannelId) => { CommonBase.add_ref_from(this, channel_ids_conv_11); });
1956 CommonBase.add_ref_from(this, config_update);
1961 * Atomically updates the [`ChannelConfig`] for the given channels.
1963 * Once the updates are applied, each eligible channel (advertised with a known short channel
1964 * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
1965 * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
1966 * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
1968 * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
1969 * `counterparty_node_id` is provided.
1971 * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
1972 * below [`MIN_CLTV_EXPIRY_DELTA`].
1974 * If an error is returned, none of the updates should be considered applied.
1976 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
1977 * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
1978 * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
1979 * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
1980 * [`ChannelUpdate`]: msgs::ChannelUpdate
1981 * [`ChannelUnavailable`]: APIError::ChannelUnavailable
1982 * [`APIMisuseError`]: APIError::APIMisuseError
1984 public update_channel_config(counterparty_node_id: Uint8Array, channel_ids: ChannelId[], config: ChannelConfig): Result_NoneAPIErrorZ {
1985 const ret: bigint = bindings.ChannelManager_update_channel_config(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)), bindings.encodeUint64Array(channel_ids.map(channel_ids_conv_11 => CommonBase.get_ptr_of(channel_ids_conv_11))), CommonBase.get_ptr_of(config));
1986 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1987 channel_ids.forEach((channel_ids_conv_11: ChannelId) => { CommonBase.add_ref_from(this, channel_ids_conv_11); });
1988 CommonBase.add_ref_from(this, config);
1993 * Attempts to forward an intercepted HTLC over the provided channel id and with the provided
1994 * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
1996 * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
1997 * channel to a receiving node if the node lacks sufficient inbound liquidity.
1999 * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
2000 * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
2001 * receiver's invoice route hints. These route hints will signal to LDK to generate an
2002 * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
2003 * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
2005 * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
2006 * you from forwarding more than you received. See
2007 * [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount
2010 * Errors if the event was not handled in time, in which case the HTLC was automatically failed
2013 * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
2014 * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
2015 * [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat
2017 public forward_intercepted_htlc(intercept_id: Uint8Array, next_hop_channel_id: ChannelId, next_node_id: Uint8Array, amt_to_forward_msat: bigint): Result_NoneAPIErrorZ {
2018 const ret: bigint = bindings.ChannelManager_forward_intercepted_htlc(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(intercept_id, 32)), CommonBase.get_ptr_of(next_hop_channel_id), bindings.encodeUint8Array(bindings.check_arr_len(next_node_id, 33)), amt_to_forward_msat);
2019 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
2020 CommonBase.add_ref_from(this, next_hop_channel_id);
2025 * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
2026 * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
2028 * Errors if the event was not handled in time, in which case the HTLC was automatically failed
2031 * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
2033 public fail_intercepted_htlc(intercept_id: Uint8Array): Result_NoneAPIErrorZ {
2034 const ret: bigint = bindings.ChannelManager_fail_intercepted_htlc(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(intercept_id, 32)));
2035 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
2040 * Processes HTLCs which are pending waiting on random forward delay.
2042 * Should only really ever be called in response to a PendingHTLCsForwardable event.
2043 * Will likely generate further events.
2045 public process_pending_htlc_forwards(): void {
2046 bindings.ChannelManager_process_pending_htlc_forwards(this.ptr);
2050 * Performs actions which should happen on startup and roughly once per minute thereafter.
2052 * This currently includes:
2053 * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
2054 * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more
2055 * than a minute, informing the network that they should no longer attempt to route over
2057 * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs
2058 * with the current [`ChannelConfig`].
2059 * Removing peers which have disconnected but and no longer have any channels.
2060 * Force-closing and removing channels which have not completed establishment in a timely manner.
2061 * Forgetting about stale outbound payments, either those that have already been fulfilled
2062 * or those awaiting an invoice that hasn't been delivered in the necessary amount of time.
2063 * The latter is determined using the system clock in `std` and the highest seen block time
2064 * minus two hours in `no-std`.
2066 * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate
2069 * [`ChannelUpdate`]: msgs::ChannelUpdate
2070 * [`ChannelConfig`]: crate::util::config::ChannelConfig
2072 public timer_tick_occurred(): void {
2073 bindings.ChannelManager_timer_tick_occurred(this.ptr);
2077 * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
2078 * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
2079 * along the path (including in our own channel on which we received it).
2081 * Note that in some cases around unclean shutdown, it is possible the payment may have
2082 * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
2083 * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment
2084 * may have already been failed automatically by LDK if it was nearing its expiration time.
2086 * While LDK will never claim a payment automatically on your behalf (i.e. without you calling
2087 * [`ChannelManager::claim_funds`]), you should still monitor for
2088 * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
2089 * startup during which time claims that were in-progress at shutdown may be replayed.
2091 public fail_htlc_backwards(payment_hash: Uint8Array): void {
2092 bindings.ChannelManager_fail_htlc_backwards(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)));
2096 * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the
2097 * reason for the failure.
2099 * See [`FailureCode`] for valid failure codes.
2101 public fail_htlc_backwards_with_reason(payment_hash: Uint8Array, failure_code: FailureCode): void {
2102 bindings.ChannelManager_fail_htlc_backwards_with_reason(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), CommonBase.get_ptr_of(failure_code));
2103 CommonBase.add_ref_from(this, failure_code);
2107 * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
2108 * [`MessageSendEvent`]s needed to claim the payment.
2110 * This method is guaranteed to ensure the payment has been claimed but only if the current
2111 * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race
2112 * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment
2113 * successful. It will generally be available in the next [`process_pending_events`] call.
2115 * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
2116 * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
2117 * event matches your expectation. If you fail to do so and call this method, you may provide
2118 * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
2120 * This function will fail the payment if it has custom TLVs with even type numbers, as we
2121 * will assume they are unknown. If you intend to accept even custom TLVs, you should use
2122 * [`claim_funds_with_known_custom_tlvs`].
2124 * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
2125 * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline
2126 * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed
2127 * [`process_pending_events`]: EventsProvider::process_pending_events
2128 * [`create_inbound_payment`]: Self::create_inbound_payment
2129 * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2130 * [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs
2132 public claim_funds(payment_preimage: Uint8Array): void {
2133 bindings.ChannelManager_claim_funds(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_preimage, 32)));
2137 * This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with
2138 * even type numbers.
2142 * You MUST check you've understood all even TLVs before using this to
2143 * claim, otherwise you may unintentionally agree to some protocol you do not understand.
2145 * [`claim_funds`]: Self::claim_funds
2147 public claim_funds_with_known_custom_tlvs(payment_preimage: Uint8Array): void {
2148 bindings.ChannelManager_claim_funds_with_known_custom_tlvs(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_preimage, 32)));
2152 * Gets the node_id held by this ChannelManager
2154 public get_our_node_id(): Uint8Array {
2155 const ret: number = bindings.ChannelManager_get_our_node_id(this.ptr);
2156 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
2161 * Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
2163 * The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
2164 * and the `counterparty_node_id` parameter is the id of the peer which has requested to open
2167 * The `user_channel_id` parameter will be provided back in
2168 * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
2169 * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
2171 * Note that this method will return an error and reject the channel, if it requires support
2172 * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
2173 * used to accept such channels.
2175 * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
2176 * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
2178 public accept_inbound_channel(temporary_channel_id: ChannelId, counterparty_node_id: Uint8Array, user_channel_id: bigint): Result_NoneAPIErrorZ {
2179 const ret: bigint = bindings.ChannelManager_accept_inbound_channel(this.ptr, CommonBase.get_ptr_of(temporary_channel_id), bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)), bindings.encodeUint128(user_channel_id));
2180 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
2181 CommonBase.add_ref_from(this, temporary_channel_id);
2186 * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
2187 * it as confirmed immediately.
2189 * The `user_channel_id` parameter will be provided back in
2190 * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
2191 * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
2193 * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
2194 * and (if the counterparty agrees), enables forwarding of payments immediately.
2196 * This fully trusts that the counterparty has honestly and correctly constructed the funding
2197 * transaction and blindly assumes that it will eventually confirm.
2199 * If it does not confirm before we decide to close the channel, or if the funding transaction
2200 * does not pay to the correct script the correct amount, *you will lose funds*.
2202 * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
2203 * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
2205 public accept_inbound_channel_from_trusted_peer_0conf(temporary_channel_id: ChannelId, counterparty_node_id: Uint8Array, user_channel_id: bigint): Result_NoneAPIErrorZ {
2206 const ret: bigint = bindings.ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(this.ptr, CommonBase.get_ptr_of(temporary_channel_id), bindings.encodeUint8Array(bindings.check_arr_len(counterparty_node_id, 33)), bindings.encodeUint128(user_channel_id));
2207 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
2208 CommonBase.add_ref_from(this, temporary_channel_id);
2213 * Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the
2214 * [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer will
2215 * not have an expiration unless otherwise set on the builder.
2219 * Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the offer.
2220 * However, if one is not found, uses a one-hop [`BlindedPath`] with
2221 * [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case,
2222 * the node must be announced, otherwise, there is no way to find a path to the introduction in
2223 * order to send the [`InvoiceRequest`].
2225 * Also, uses a derived signing pubkey in the offer for recipient privacy.
2229 * Requires a direct connection to the introduction node in the responding [`InvoiceRequest`]'s
2234 * Errors if the parameterized [`Router`] is unable to create a blinded path for the offer.
2236 * [`Offer`]: crate::offers::offer::Offer
2237 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
2239 public create_offer_builder(): Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ {
2240 const ret: bigint = bindings.ChannelManager_create_offer_builder(this.ptr);
2241 const ret_hu_conv: Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ = Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
2246 * Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
2247 * [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund.
2251 * The provided `payment_id` is used to ensure that only one invoice is paid for the refund.
2252 * See [Avoiding Duplicate Payments] for other requirements once the payment has been sent.
2254 * The builder will have the provided expiration set. Any changes to the expiration on the
2255 * returned builder will not be honored by [`ChannelManager`]. For `no-std`, the highest seen
2256 * block time minus two hours is used for the current time when determining if the refund has
2259 * To revoke the refund, use [`ChannelManager::abandon_payment`] prior to receiving the
2260 * invoice. If abandoned, or an invoice isn't received before expiration, the payment will fail
2261 * with an [`Event::InvoiceRequestFailed`].
2263 * If `max_total_routing_fee_msat` is not specified, The default from
2264 * [`RouteParameters::from_payment_params_and_value`] is applied.
2268 * Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the refund.
2269 * However, if one is not found, uses a one-hop [`BlindedPath`] with
2270 * [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case,
2271 * the node must be announced, otherwise, there is no way to find a path to the introduction in
2272 * order to send the [`Bolt12Invoice`].
2274 * Also, uses a derived payer id in the refund for payer privacy.
2278 * Requires a direct connection to an introduction node in the responding
2279 * [`Bolt12Invoice::payment_paths`].
2284 * - a duplicate `payment_id` is provided given the caveats in the aforementioned link,
2285 * - `amount_msats` is invalid, or
2286 * - the parameterized [`Router`] is unable to create a blinded path for the refund.
2288 * [`Refund`]: crate::offers::refund::Refund
2289 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
2290 * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
2291 * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
2293 public create_refund_builder(amount_msats: bigint, absolute_expiry: bigint, payment_id: Uint8Array, retry_strategy: Retry, max_total_routing_fee_msat: Option_u64Z): Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ {
2294 const ret: bigint = bindings.ChannelManager_create_refund_builder(this.ptr, amount_msats, absolute_expiry, bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)), CommonBase.get_ptr_of(retry_strategy), CommonBase.get_ptr_of(max_total_routing_fee_msat));
2295 const ret_hu_conv: Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ = Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
2296 CommonBase.add_ref_from(this, retry_strategy);
2297 CommonBase.add_ref_from(this, max_total_routing_fee_msat);
2302 * Pays for an [`Offer`] using the given parameters by creating an [`InvoiceRequest`] and
2303 * enqueuing it to be sent via an onion message. [`ChannelManager`] will pay the actual
2304 * [`Bolt12Invoice`] once it is received.
2306 * Uses [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is recognized by
2307 * the [`ChannelManager`] when handling a [`Bolt12Invoice`] message in response to the request.
2308 * The optional parameters are used in the builder, if `Some`:
2309 * - `quantity` for [`InvoiceRequest::quantity`] which must be set if
2310 * [`Offer::expects_quantity`] is `true`.
2311 * - `amount_msats` if overpaying what is required for the given `quantity` is desired, and
2312 * - `payer_note` for [`InvoiceRequest::payer_note`].
2314 * If `max_total_routing_fee_msat` is not specified, The default from
2315 * [`RouteParameters::from_payment_params_and_value`] is applied.
2319 * The provided `payment_id` is used to ensure that only one invoice is paid for the request
2320 * when received. See [Avoiding Duplicate Payments] for other requirements once the payment has
2323 * To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the
2324 * invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the
2325 * payment will fail with an [`Event::InvoiceRequestFailed`].
2329 * Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`]
2330 * as the introduction node and a derived payer id for payer privacy. As such, currently, the
2331 * node must be announced. Otherwise, there is no way to find a path to the introduction node
2332 * in order to send the [`Bolt12Invoice`].
2336 * Requires a direct connection to an introduction node in [`Offer::paths`] or to
2337 * [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding
2338 * [`Bolt12Invoice::payment_paths`].
2343 * - a duplicate `payment_id` is provided given the caveats in the aforementioned link,
2344 * - the provided parameters are invalid for the offer,
2345 * - the offer is for an unsupported chain, or
2346 * - the parameterized [`Router`] is unable to create a blinded reply path for the invoice
2349 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
2350 * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
2351 * [`InvoiceRequest::payer_note`]: crate::offers::invoice_request::InvoiceRequest::payer_note
2352 * [`InvoiceRequestBuilder`]: crate::offers::invoice_request::InvoiceRequestBuilder
2353 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
2354 * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
2355 * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
2357 public pay_for_offer(offer: Offer, quantity: Option_u64Z, amount_msats: Option_u64Z, payer_note: Option_StrZ, payment_id: Uint8Array, retry_strategy: Retry, max_total_routing_fee_msat: Option_u64Z): Result_NoneBolt12SemanticErrorZ {
2358 const ret: bigint = bindings.ChannelManager_pay_for_offer(this.ptr, CommonBase.get_ptr_of(offer), CommonBase.get_ptr_of(quantity), CommonBase.get_ptr_of(amount_msats), CommonBase.get_ptr_of(payer_note), bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)), CommonBase.get_ptr_of(retry_strategy), CommonBase.get_ptr_of(max_total_routing_fee_msat));
2359 const ret_hu_conv: Result_NoneBolt12SemanticErrorZ = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
2360 CommonBase.add_ref_from(this, offer);
2361 CommonBase.add_ref_from(this, quantity);
2362 CommonBase.add_ref_from(this, amount_msats);
2363 CommonBase.add_ref_from(this, payer_note);
2364 CommonBase.add_ref_from(this, retry_strategy);
2365 CommonBase.add_ref_from(this, max_total_routing_fee_msat);
2370 * Creates a [`Bolt12Invoice`] for a [`Refund`] and enqueues it to be sent via an onion
2373 * The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a
2374 * [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding
2375 * [`PaymentPreimage`]. It is returned purely for informational purposes.
2379 * Requires a direct connection to an introduction node in [`Refund::paths`] or to
2380 * [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
2381 * node meeting the aforementioned criteria, but there's no guarantee that they will be
2382 * received and no retries will be made.
2387 * - the refund is for an unsupported chain, or
2388 * - the parameterized [`Router`] is unable to create a blinded payment path or reply path for
2391 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
2393 public request_refund_payment(refund: Refund): Result_Bolt12InvoiceBolt12SemanticErrorZ {
2394 const ret: bigint = bindings.ChannelManager_request_refund_payment(this.ptr, CommonBase.get_ptr_of(refund));
2395 const ret_hu_conv: Result_Bolt12InvoiceBolt12SemanticErrorZ = Result_Bolt12InvoiceBolt12SemanticErrorZ.constr_from_ptr(ret);
2396 CommonBase.add_ref_from(this, refund);
2401 * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
2404 * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
2405 * [`PaymentHash`] and [`PaymentPreimage`] for you.
2407 * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`] event, which
2408 * will have the [`PaymentClaimable::purpose`] return `Some` for [`PaymentPurpose::preimage`]. That
2409 * should then be passed directly to [`claim_funds`].
2411 * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
2413 * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
2414 * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
2418 * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
2419 * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
2421 * Errors if `min_value_msat` is greater than total bitcoin supply.
2423 * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
2424 * on versions of LDK prior to 0.0.114.
2426 * [`claim_funds`]: Self::claim_funds
2427 * [`PaymentClaimable`]: events::Event::PaymentClaimable
2428 * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose
2429 * [`PaymentPurpose::preimage`]: events::PaymentPurpose::preimage
2430 * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2432 public create_inbound_payment(min_value_msat: Option_u64Z, invoice_expiry_delta_secs: number, min_final_cltv_expiry_delta: Option_u16Z): Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ {
2433 const ret: bigint = bindings.ChannelManager_create_inbound_payment(this.ptr, CommonBase.get_ptr_of(min_value_msat), invoice_expiry_delta_secs, CommonBase.get_ptr_of(min_final_cltv_expiry_delta));
2434 const ret_hu_conv: Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
2435 CommonBase.add_ref_from(this, min_value_msat);
2436 CommonBase.add_ref_from(this, min_final_cltv_expiry_delta);
2441 * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
2442 * stored external to LDK.
2444 * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a
2445 * payment secret fetched via this method or [`create_inbound_payment`], and which is at least
2446 * the `min_value_msat` provided here, if one is provided.
2448 * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
2449 * note that LDK will not stop you from registering duplicate payment hashes for inbound
2452 * `min_value_msat` should be set if the invoice being generated contains a value. Any payment
2453 * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
2454 * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the
2455 * sender \"proof-of-payment\" unless they have paid the required amount.
2457 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
2458 * in excess of the current time. This should roughly match the expiry time set in the invoice.
2459 * After this many seconds, we will remove the inbound payment, resulting in any attempts to
2460 * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
2461 * invoices when no timeout is set.
2463 * Note that we use block header time to time-out pending inbound payments (with some margin
2464 * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
2465 * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry.
2466 * If you need exact expiry semantics, you should enforce them upon receipt of
2467 * [`PaymentClaimable`].
2469 * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta`
2470 * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
2472 * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
2473 * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
2477 * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
2478 * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
2480 * Errors if `min_value_msat` is greater than total bitcoin supply.
2482 * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
2483 * on versions of LDK prior to 0.0.114.
2485 * [`create_inbound_payment`]: Self::create_inbound_payment
2486 * [`PaymentClaimable`]: events::Event::PaymentClaimable
2488 public create_inbound_payment_for_hash(payment_hash: Uint8Array, min_value_msat: Option_u64Z, invoice_expiry_delta_secs: number, min_final_cltv_expiry: Option_u16Z): Result_ThirtyTwoBytesNoneZ {
2489 const ret: bigint = bindings.ChannelManager_create_inbound_payment_for_hash(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), CommonBase.get_ptr_of(min_value_msat), invoice_expiry_delta_secs, CommonBase.get_ptr_of(min_final_cltv_expiry));
2490 const ret_hu_conv: Result_ThirtyTwoBytesNoneZ = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
2491 CommonBase.add_ref_from(this, min_value_msat);
2492 CommonBase.add_ref_from(this, min_final_cltv_expiry);
2497 * Gets an LDK-generated payment preimage from a payment hash and payment secret that were
2498 * previously returned from [`create_inbound_payment`].
2500 * [`create_inbound_payment`]: Self::create_inbound_payment
2502 public get_payment_preimage(payment_hash: Uint8Array, payment_secret: Uint8Array): Result_ThirtyTwoBytesAPIErrorZ {
2503 const ret: bigint = bindings.ChannelManager_get_payment_preimage(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), bindings.encodeUint8Array(bindings.check_arr_len(payment_secret, 32)));
2504 const ret_hu_conv: Result_ThirtyTwoBytesAPIErrorZ = Result_ThirtyTwoBytesAPIErrorZ.constr_from_ptr(ret);
2509 * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
2510 * are used when constructing the phantom invoice's route hints.
2512 * [phantom node payments]: crate::sign::PhantomKeysManager
2514 public get_phantom_scid(): bigint {
2515 const ret: bigint = bindings.ChannelManager_get_phantom_scid(this.ptr);
2520 * Gets route hints for use in receiving [phantom node payments].
2522 * [phantom node payments]: crate::sign::PhantomKeysManager
2524 public get_phantom_route_hints(): PhantomRouteHints {
2525 const ret: bigint = bindings.ChannelManager_get_phantom_route_hints(this.ptr);
2526 const ret_hu_conv: PhantomRouteHints = new PhantomRouteHints(null, ret);
2527 CommonBase.add_ref_from(ret_hu_conv, this);
2532 * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are
2533 * used when constructing the route hints for HTLCs intended to be intercepted. See
2534 * [`ChannelManager::forward_intercepted_htlc`].
2536 * Note that this method is not guaranteed to return unique values, you may need to call it a few
2537 * times to get a unique scid.
2539 public get_intercept_scid(): bigint {
2540 const ret: bigint = bindings.ChannelManager_get_intercept_scid(this.ptr);
2545 * Gets inflight HTLC information by processing pending outbound payments that are in
2546 * our channels. May be used during pathfinding to account for in-use channel liquidity.
2548 public compute_inflight_htlcs(): InFlightHtlcs {
2549 const ret: bigint = bindings.ChannelManager_compute_inflight_htlcs(this.ptr);
2550 const ret_hu_conv: InFlightHtlcs = new InFlightHtlcs(null, ret);
2551 CommonBase.add_ref_from(ret_hu_conv, this);
2556 * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
2557 * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
2559 public as_MessageSendEventsProvider(): MessageSendEventsProvider {
2560 const ret: bigint = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
2561 const ret_hu_conv: MessageSendEventsProvider = new MessageSendEventsProvider(null, ret);
2562 CommonBase.add_ref_from(ret_hu_conv, this);
2567 * Constructs a new EventsProvider which calls the relevant methods on this_arg.
2568 * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
2570 public as_EventsProvider(): EventsProvider {
2571 const ret: bigint = bindings.ChannelManager_as_EventsProvider(this.ptr);
2572 const ret_hu_conv: EventsProvider = new EventsProvider(null, ret);
2573 CommonBase.add_ref_from(ret_hu_conv, this);
2578 * Constructs a new Listen which calls the relevant methods on this_arg.
2579 * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
2581 public as_Listen(): Listen {
2582 const ret: bigint = bindings.ChannelManager_as_Listen(this.ptr);
2583 const ret_hu_conv: Listen = new Listen(null, ret);
2584 CommonBase.add_ref_from(ret_hu_conv, this);
2589 * Constructs a new Confirm which calls the relevant methods on this_arg.
2590 * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
2592 public as_Confirm(): Confirm {
2593 const ret: bigint = bindings.ChannelManager_as_Confirm(this.ptr);
2594 const ret_hu_conv: Confirm = new Confirm(null, ret);
2595 CommonBase.add_ref_from(ret_hu_conv, this);
2600 * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or
2601 * may have events that need processing.
2603 * In order to check if this [`ChannelManager`] needs persisting, call
2604 * [`Self::get_and_clear_needs_persistence`].
2606 * Note that callbacks registered on the [`Future`] MUST NOT call back into this
2607 * [`ChannelManager`] and should instead register actions to be taken later.
2609 public get_event_or_persistence_needed_future(): Future {
2610 const ret: bigint = bindings.ChannelManager_get_event_or_persistence_needed_future(this.ptr);
2611 const ret_hu_conv: Future = new Future(null, ret);
2612 CommonBase.add_ref_from(ret_hu_conv, this);
2617 * Returns true if this [`ChannelManager`] needs to be persisted.
2619 * See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that
2620 * indicates this should be checked.
2622 public get_and_clear_needs_persistence(): boolean {
2623 const ret: boolean = bindings.ChannelManager_get_and_clear_needs_persistence(this.ptr);
2628 * Gets the latest best block which was connected either via the [`chain::Listen`] or
2629 * [`chain::Confirm`] interfaces.
2631 public current_best_block(): BestBlock {
2632 const ret: bigint = bindings.ChannelManager_current_best_block(this.ptr);
2633 const ret_hu_conv: BestBlock = new BestBlock(null, ret);
2634 CommonBase.add_ref_from(ret_hu_conv, this);
2639 * Fetches the set of [`NodeFeatures`] flags that are provided by or required by
2640 * [`ChannelManager`].
2642 public node_features(): NodeFeatures {
2643 const ret: bigint = bindings.ChannelManager_node_features(this.ptr);
2644 const ret_hu_conv: NodeFeatures = new NodeFeatures(null, ret);
2645 CommonBase.add_ref_from(ret_hu_conv, this);
2650 * Fetches the set of [`ChannelFeatures`] flags that are provided by or required by
2651 * [`ChannelManager`].
2653 public channel_features(): ChannelFeatures {
2654 const ret: bigint = bindings.ChannelManager_channel_features(this.ptr);
2655 const ret_hu_conv: ChannelFeatures = new ChannelFeatures(null, ret);
2656 CommonBase.add_ref_from(ret_hu_conv, this);
2661 * Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by
2662 * [`ChannelManager`].
2664 public channel_type_features(): ChannelTypeFeatures {
2665 const ret: bigint = bindings.ChannelManager_channel_type_features(this.ptr);
2666 const ret_hu_conv: ChannelTypeFeatures = new ChannelTypeFeatures(null, ret);
2667 CommonBase.add_ref_from(ret_hu_conv, this);
2672 * Fetches the set of [`InitFeatures`] flags that are provided by or required by
2673 * [`ChannelManager`].
2675 public init_features(): InitFeatures {
2676 const ret: bigint = bindings.ChannelManager_init_features(this.ptr);
2677 const ret_hu_conv: InitFeatures = new InitFeatures(null, ret);
2678 CommonBase.add_ref_from(ret_hu_conv, this);
2683 * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
2684 * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
2686 public as_ChannelMessageHandler(): ChannelMessageHandler {
2687 const ret: bigint = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
2688 const ret_hu_conv: ChannelMessageHandler = new ChannelMessageHandler(null, ret);
2689 CommonBase.add_ref_from(ret_hu_conv, this);
2694 * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg.
2695 * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is
2697 public as_OffersMessageHandler(): OffersMessageHandler {
2698 const ret: bigint = bindings.ChannelManager_as_OffersMessageHandler(this.ptr);
2699 const ret_hu_conv: OffersMessageHandler = new OffersMessageHandler(null, ret);
2700 CommonBase.add_ref_from(ret_hu_conv, this);
2705 * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg.
2706 * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is
2708 public as_NodeIdLookUp(): NodeIdLookUp {
2709 const ret: bigint = bindings.ChannelManager_as_NodeIdLookUp(this.ptr);
2710 const ret_hu_conv: NodeIdLookUp = new NodeIdLookUp(null, ret);
2711 CommonBase.add_ref_from(ret_hu_conv, this);
2716 * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
2718 public write(): Uint8Array {
2719 const ret: number = bindings.ChannelManager_write(this.ptr);
2720 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);