[TS] Update auto-generated TypeScript Bindings
[ldk-java] / ts / structs / ChannelManager.mts
1 import { TxOut } from '../structs/TxOut.mjs';
2 import { AccessError } from '../enums/AccessError.mjs';
3 import { COption_NoneZ } from '../enums/COption_NoneZ.mjs';
4 import { ChannelMonitorUpdateErr } from '../enums/ChannelMonitorUpdateErr.mjs';
5 import { ConfirmationTarget } from '../enums/ConfirmationTarget.mjs';
6 import { Level } from '../enums/Level.mjs';
7 import { Network } from '../enums/Network.mjs';
8 import { Secp256k1Error } from '../enums/Secp256k1Error.mjs';
9 import { ChannelConfig } from '../structs/ChannelConfig.mjs';
10 import { DecodeError } from '../structs/DecodeError.mjs';
11 import { Result_ChannelConfigDecodeErrorZ } from '../structs/Result_ChannelConfigDecodeErrorZ.mjs';
12 import { OutPoint } from '../structs/OutPoint.mjs';
13 import { Result_OutPointDecodeErrorZ } from '../structs/Result_OutPointDecodeErrorZ.mjs';
14 import { Result_SecretKeyErrorZ } from '../structs/Result_SecretKeyErrorZ.mjs';
15 import { Result_PublicKeyErrorZ } from '../structs/Result_PublicKeyErrorZ.mjs';
16 import { TxCreationKeys } from '../structs/TxCreationKeys.mjs';
17 import { Result_TxCreationKeysDecodeErrorZ } from '../structs/Result_TxCreationKeysDecodeErrorZ.mjs';
18 import { ChannelPublicKeys } from '../structs/ChannelPublicKeys.mjs';
19 import { Result_ChannelPublicKeysDecodeErrorZ } from '../structs/Result_ChannelPublicKeysDecodeErrorZ.mjs';
20 import { Result_TxCreationKeysErrorZ } from '../structs/Result_TxCreationKeysErrorZ.mjs';
21 import { Option_u32Z } from '../structs/Option_u32Z.mjs';
22 import { HTLCOutputInCommitment } from '../structs/HTLCOutputInCommitment.mjs';
23 import { Result_HTLCOutputInCommitmentDecodeErrorZ } from '../structs/Result_HTLCOutputInCommitmentDecodeErrorZ.mjs';
24 import { CounterpartyChannelTransactionParameters } from '../structs/CounterpartyChannelTransactionParameters.mjs';
25 import { Result_CounterpartyChannelTransactionParametersDecodeErrorZ } from '../structs/Result_CounterpartyChannelTransactionParametersDecodeErrorZ.mjs';
26 import { ChannelTransactionParameters } from '../structs/ChannelTransactionParameters.mjs';
27 import { Result_ChannelTransactionParametersDecodeErrorZ } from '../structs/Result_ChannelTransactionParametersDecodeErrorZ.mjs';
28 import { HolderCommitmentTransaction } from '../structs/HolderCommitmentTransaction.mjs';
29 import { Result_HolderCommitmentTransactionDecodeErrorZ } from '../structs/Result_HolderCommitmentTransactionDecodeErrorZ.mjs';
30 import { BuiltCommitmentTransaction } from '../structs/BuiltCommitmentTransaction.mjs';
31 import { Result_BuiltCommitmentTransactionDecodeErrorZ } from '../structs/Result_BuiltCommitmentTransactionDecodeErrorZ.mjs';
32 import { TrustedClosingTransaction } from '../structs/TrustedClosingTransaction.mjs';
33 import { Result_TrustedClosingTransactionNoneZ } from '../structs/Result_TrustedClosingTransactionNoneZ.mjs';
34 import { CommitmentTransaction } from '../structs/CommitmentTransaction.mjs';
35 import { Result_CommitmentTransactionDecodeErrorZ } from '../structs/Result_CommitmentTransactionDecodeErrorZ.mjs';
36 import { TrustedCommitmentTransaction } from '../structs/TrustedCommitmentTransaction.mjs';
37 import { Result_TrustedCommitmentTransactionNoneZ } from '../structs/Result_TrustedCommitmentTransactionNoneZ.mjs';
38 import { Result_CVec_SignatureZNoneZ } from '../structs/Result_CVec_SignatureZNoneZ.mjs';
39 import { ShutdownScript } from '../structs/ShutdownScript.mjs';
40 import { Result_ShutdownScriptDecodeErrorZ } from '../structs/Result_ShutdownScriptDecodeErrorZ.mjs';
41 import { InvalidShutdownScript } from '../structs/InvalidShutdownScript.mjs';
42 import { Result_ShutdownScriptInvalidShutdownScriptZ } from '../structs/Result_ShutdownScriptInvalidShutdownScriptZ.mjs';
43 import { Type, TypeInterface } from '../structs/Type.mjs';
44 import { Option_TypeZ } from '../structs/Option_TypeZ.mjs';
45 import { Result_COption_TypeZDecodeErrorZ } from '../structs/Result_COption_TypeZDecodeErrorZ.mjs';
46 import { Result_StringErrorZ } from '../structs/Result_StringErrorZ.mjs';
47 import { ChannelMonitorUpdate } from '../structs/ChannelMonitorUpdate.mjs';
48 import { Result_ChannelMonitorUpdateDecodeErrorZ } from '../structs/Result_ChannelMonitorUpdateDecodeErrorZ.mjs';
49 import { HTLCUpdate } from '../structs/HTLCUpdate.mjs';
50 import { MonitorEvent } from '../structs/MonitorEvent.mjs';
51 import { Option_MonitorEventZ } from '../structs/Option_MonitorEventZ.mjs';
52 import { Result_COption_MonitorEventZDecodeErrorZ } from '../structs/Result_COption_MonitorEventZDecodeErrorZ.mjs';
53 import { Result_HTLCUpdateDecodeErrorZ } from '../structs/Result_HTLCUpdateDecodeErrorZ.mjs';
54 import { Result_NoneNoneZ } from '../structs/Result_NoneNoneZ.mjs';
55 import { TwoTuple_OutPointScriptZ } from '../structs/TwoTuple_OutPointScriptZ.mjs';
56 import { TwoTuple_u32ScriptZ } from '../structs/TwoTuple_u32ScriptZ.mjs';
57 import { TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ } from '../structs/TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ.mjs';
58 import { PaymentPurpose } from '../structs/PaymentPurpose.mjs';
59 import { Option_u64Z } from '../structs/Option_u64Z.mjs';
60 import { ChannelUpdate } from '../structs/ChannelUpdate.mjs';
61 import { NetworkUpdate } from '../structs/NetworkUpdate.mjs';
62 import { Option_NetworkUpdateZ } from '../structs/Option_NetworkUpdateZ.mjs';
63 import { RouteHop } from '../structs/RouteHop.mjs';
64 import { RouteParameters } from '../structs/RouteParameters.mjs';
65 import { DelayedPaymentOutputDescriptor } from '../structs/DelayedPaymentOutputDescriptor.mjs';
66 import { StaticPaymentOutputDescriptor } from '../structs/StaticPaymentOutputDescriptor.mjs';
67 import { SpendableOutputDescriptor } from '../structs/SpendableOutputDescriptor.mjs';
68 import { ClosureReason } from '../structs/ClosureReason.mjs';
69 import { Event } from '../structs/Event.mjs';
70 import { TwoTuple_usizeTransactionZ } from '../structs/TwoTuple_usizeTransactionZ.mjs';
71 import { TwoTuple_u32TxOutZ } from '../structs/TwoTuple_u32TxOutZ.mjs';
72 import { TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ } from '../structs/TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ.mjs';
73 import { Balance } from '../structs/Balance.mjs';
74 import { TwoTuple_SignatureCVec_SignatureZZ } from '../structs/TwoTuple_SignatureCVec_SignatureZZ.mjs';
75 import { Result_C2Tuple_SignatureCVec_SignatureZZNoneZ } from '../structs/Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.mjs';
76 import { Result_SignatureNoneZ } from '../structs/Result_SignatureNoneZ.mjs';
77 import { ClosingTransaction } from '../structs/ClosingTransaction.mjs';
78 import { UnsignedChannelAnnouncement } from '../structs/UnsignedChannelAnnouncement.mjs';
79 import { BaseSign, BaseSignInterface } from '../structs/BaseSign.mjs';
80 import { Sign, SignInterface } from '../structs/Sign.mjs';
81 import { ChannelMonitor } from '../structs/ChannelMonitor.mjs';
82 import { TwoTuple_BlockHashChannelMonitorZ } from '../structs/TwoTuple_BlockHashChannelMonitorZ.mjs';
83 import { Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ } from '../structs/Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.mjs';
84 import { Result_RouteHopDecodeErrorZ } from '../structs/Result_RouteHopDecodeErrorZ.mjs';
85 import { Route } from '../structs/Route.mjs';
86 import { Result_RouteDecodeErrorZ } from '../structs/Result_RouteDecodeErrorZ.mjs';
87 import { Result_RouteParametersDecodeErrorZ } from '../structs/Result_RouteParametersDecodeErrorZ.mjs';
88 import { RouteHint } from '../structs/RouteHint.mjs';
89 import { Payee } from '../structs/Payee.mjs';
90 import { Result_PayeeDecodeErrorZ } from '../structs/Result_PayeeDecodeErrorZ.mjs';
91 import { RouteHintHop } from '../structs/RouteHintHop.mjs';
92 import { Result_RouteHintDecodeErrorZ } from '../structs/Result_RouteHintDecodeErrorZ.mjs';
93 import { Result_RouteHintHopDecodeErrorZ } from '../structs/Result_RouteHintHopDecodeErrorZ.mjs';
94 import { ChannelDetails } from '../structs/ChannelDetails.mjs';
95 import { LightningError } from '../structs/LightningError.mjs';
96 import { Result_RouteLightningErrorZ } from '../structs/Result_RouteLightningErrorZ.mjs';
97 import { Result_NoneLightningErrorZ } from '../structs/Result_NoneLightningErrorZ.mjs';
98 import { TwoTuple_PublicKeyTypeZ } from '../structs/TwoTuple_PublicKeyTypeZ.mjs';
99 import { AcceptChannel } from '../structs/AcceptChannel.mjs';
100 import { OpenChannel } from '../structs/OpenChannel.mjs';
101 import { FundingCreated } from '../structs/FundingCreated.mjs';
102 import { FundingSigned } from '../structs/FundingSigned.mjs';
103 import { FundingLocked } from '../structs/FundingLocked.mjs';
104 import { AnnouncementSignatures } from '../structs/AnnouncementSignatures.mjs';
105 import { CommitmentUpdate } from '../structs/CommitmentUpdate.mjs';
106 import { RevokeAndACK } from '../structs/RevokeAndACK.mjs';
107 import { ClosingSigned } from '../structs/ClosingSigned.mjs';
108 import { Shutdown } from '../structs/Shutdown.mjs';
109 import { ChannelReestablish } from '../structs/ChannelReestablish.mjs';
110 import { ChannelAnnouncement } from '../structs/ChannelAnnouncement.mjs';
111 import { NodeAnnouncement } from '../structs/NodeAnnouncement.mjs';
112 import { ErrorMessage } from '../structs/ErrorMessage.mjs';
113 import { ErrorAction } from '../structs/ErrorAction.mjs';
114 import { QueryChannelRange } from '../structs/QueryChannelRange.mjs';
115 import { QueryShortChannelIds } from '../structs/QueryShortChannelIds.mjs';
116 import { ReplyChannelRange } from '../structs/ReplyChannelRange.mjs';
117 import { MessageSendEvent } from '../structs/MessageSendEvent.mjs';
118 import { Result_boolLightningErrorZ } from '../structs/Result_boolLightningErrorZ.mjs';
119 import { ThreeTuple_ChannelAnnouncementChannelUpdateChannelUpdateZ } from '../structs/ThreeTuple_ChannelAnnouncementChannelUpdateChannelUpdateZ.mjs';
120 import { PeerHandleError } from '../structs/PeerHandleError.mjs';
121 import { Result_CVec_u8ZPeerHandleErrorZ } from '../structs/Result_CVec_u8ZPeerHandleErrorZ.mjs';
122 import { Result_NonePeerHandleErrorZ } from '../structs/Result_NonePeerHandleErrorZ.mjs';
123 import { Result_boolPeerHandleErrorZ } from '../structs/Result_boolPeerHandleErrorZ.mjs';
124 import { Result_TxOutAccessErrorZ } from '../structs/Result_TxOutAccessErrorZ.mjs';
125 import { Result_NoneChannelMonitorUpdateErrZ } from '../structs/Result_NoneChannelMonitorUpdateErrZ.mjs';
126 import { Option_C2Tuple_usizeTransactionZZ } from '../structs/Option_C2Tuple_usizeTransactionZZ.mjs';
127 import { Option_ClosureReasonZ } from '../structs/Option_ClosureReasonZ.mjs';
128 import { Result_COption_ClosureReasonZDecodeErrorZ } from '../structs/Result_COption_ClosureReasonZDecodeErrorZ.mjs';
129 import { Option_EventZ } from '../structs/Option_EventZ.mjs';
130 import { Result_COption_EventZDecodeErrorZ } from '../structs/Result_COption_EventZDecodeErrorZ.mjs';
131 import { NodeId } from '../structs/NodeId.mjs';
132 import { Result_NodeIdDecodeErrorZ } from '../structs/Result_NodeIdDecodeErrorZ.mjs';
133 import { Result_COption_NetworkUpdateZDecodeErrorZ } from '../structs/Result_COption_NetworkUpdateZDecodeErrorZ.mjs';
134 import { Access, AccessInterface } from '../structs/Access.mjs';
135 import { Option_AccessZ } from '../structs/Option_AccessZ.mjs';
136 import { DirectionalChannelInfo } from '../structs/DirectionalChannelInfo.mjs';
137 import { Result_DirectionalChannelInfoDecodeErrorZ } from '../structs/Result_DirectionalChannelInfoDecodeErrorZ.mjs';
138 import { ChannelInfo } from '../structs/ChannelInfo.mjs';
139 import { Result_ChannelInfoDecodeErrorZ } from '../structs/Result_ChannelInfoDecodeErrorZ.mjs';
140 import { RoutingFees } from '../structs/RoutingFees.mjs';
141 import { Result_RoutingFeesDecodeErrorZ } from '../structs/Result_RoutingFeesDecodeErrorZ.mjs';
142 import { NetAddress } from '../structs/NetAddress.mjs';
143 import { NodeAnnouncementInfo } from '../structs/NodeAnnouncementInfo.mjs';
144 import { Result_NodeAnnouncementInfoDecodeErrorZ } from '../structs/Result_NodeAnnouncementInfoDecodeErrorZ.mjs';
145 import { NodeInfo } from '../structs/NodeInfo.mjs';
146 import { Result_NodeInfoDecodeErrorZ } from '../structs/Result_NodeInfoDecodeErrorZ.mjs';
147 import { NetworkGraph } from '../structs/NetworkGraph.mjs';
148 import { Result_NetworkGraphDecodeErrorZ } from '../structs/Result_NetworkGraphDecodeErrorZ.mjs';
149 import { Option_CVec_NetAddressZZ } from '../structs/Option_CVec_NetAddressZZ.mjs';
150 import { ScoringParameters } from '../structs/ScoringParameters.mjs';
151 import { Result_ScoringParametersDecodeErrorZ } from '../structs/Result_ScoringParametersDecodeErrorZ.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 { InvoiceFeatures } from '../structs/InvoiceFeatures.mjs';
159 import { Result_InvoiceFeaturesDecodeErrorZ } from '../structs/Result_InvoiceFeaturesDecodeErrorZ.mjs';
160 import { ChannelTypeFeatures } from '../structs/ChannelTypeFeatures.mjs';
161 import { Result_ChannelTypeFeaturesDecodeErrorZ } from '../structs/Result_ChannelTypeFeaturesDecodeErrorZ.mjs';
162 import { Result_NetAddressDecodeErrorZ } from '../structs/Result_NetAddressDecodeErrorZ.mjs';
163 import { UpdateAddHTLC } from '../structs/UpdateAddHTLC.mjs';
164 import { UpdateFulfillHTLC } from '../structs/UpdateFulfillHTLC.mjs';
165 import { UpdateFailHTLC } from '../structs/UpdateFailHTLC.mjs';
166 import { UpdateFailMalformedHTLC } from '../structs/UpdateFailMalformedHTLC.mjs';
167 import { Result_AcceptChannelDecodeErrorZ } from '../structs/Result_AcceptChannelDecodeErrorZ.mjs';
168 import { Result_AnnouncementSignaturesDecodeErrorZ } from '../structs/Result_AnnouncementSignaturesDecodeErrorZ.mjs';
169 import { Result_ChannelReestablishDecodeErrorZ } from '../structs/Result_ChannelReestablishDecodeErrorZ.mjs';
170 import { Result_ClosingSignedDecodeErrorZ } from '../structs/Result_ClosingSignedDecodeErrorZ.mjs';
171 import { ClosingSignedFeeRange } from '../structs/ClosingSignedFeeRange.mjs';
172 import { Result_ClosingSignedFeeRangeDecodeErrorZ } from '../structs/Result_ClosingSignedFeeRangeDecodeErrorZ.mjs';
173 import { CommitmentSigned } from '../structs/CommitmentSigned.mjs';
174 import { Result_CommitmentSignedDecodeErrorZ } from '../structs/Result_CommitmentSignedDecodeErrorZ.mjs';
175 import { Result_FundingCreatedDecodeErrorZ } from '../structs/Result_FundingCreatedDecodeErrorZ.mjs';
176 import { Result_FundingSignedDecodeErrorZ } from '../structs/Result_FundingSignedDecodeErrorZ.mjs';
177 import { Result_FundingLockedDecodeErrorZ } from '../structs/Result_FundingLockedDecodeErrorZ.mjs';
178 import { Init } from '../structs/Init.mjs';
179 import { Result_InitDecodeErrorZ } from '../structs/Result_InitDecodeErrorZ.mjs';
180 import { Result_OpenChannelDecodeErrorZ } from '../structs/Result_OpenChannelDecodeErrorZ.mjs';
181 import { Result_RevokeAndACKDecodeErrorZ } from '../structs/Result_RevokeAndACKDecodeErrorZ.mjs';
182 import { Result_ShutdownDecodeErrorZ } from '../structs/Result_ShutdownDecodeErrorZ.mjs';
183 import { Result_UpdateFailHTLCDecodeErrorZ } from '../structs/Result_UpdateFailHTLCDecodeErrorZ.mjs';
184 import { Result_UpdateFailMalformedHTLCDecodeErrorZ } from '../structs/Result_UpdateFailMalformedHTLCDecodeErrorZ.mjs';
185 import { UpdateFee } from '../structs/UpdateFee.mjs';
186 import { Result_UpdateFeeDecodeErrorZ } from '../structs/Result_UpdateFeeDecodeErrorZ.mjs';
187 import { Result_UpdateFulfillHTLCDecodeErrorZ } from '../structs/Result_UpdateFulfillHTLCDecodeErrorZ.mjs';
188 import { Result_UpdateAddHTLCDecodeErrorZ } from '../structs/Result_UpdateAddHTLCDecodeErrorZ.mjs';
189 import { Ping } from '../structs/Ping.mjs';
190 import { Result_PingDecodeErrorZ } from '../structs/Result_PingDecodeErrorZ.mjs';
191 import { Pong } from '../structs/Pong.mjs';
192 import { Result_PongDecodeErrorZ } from '../structs/Result_PongDecodeErrorZ.mjs';
193 import { Result_UnsignedChannelAnnouncementDecodeErrorZ } from '../structs/Result_UnsignedChannelAnnouncementDecodeErrorZ.mjs';
194 import { Result_ChannelAnnouncementDecodeErrorZ } from '../structs/Result_ChannelAnnouncementDecodeErrorZ.mjs';
195 import { UnsignedChannelUpdate } from '../structs/UnsignedChannelUpdate.mjs';
196 import { Result_UnsignedChannelUpdateDecodeErrorZ } from '../structs/Result_UnsignedChannelUpdateDecodeErrorZ.mjs';
197 import { Result_ChannelUpdateDecodeErrorZ } from '../structs/Result_ChannelUpdateDecodeErrorZ.mjs';
198 import { Result_ErrorMessageDecodeErrorZ } from '../structs/Result_ErrorMessageDecodeErrorZ.mjs';
199 import { UnsignedNodeAnnouncement } from '../structs/UnsignedNodeAnnouncement.mjs';
200 import { Result_UnsignedNodeAnnouncementDecodeErrorZ } from '../structs/Result_UnsignedNodeAnnouncementDecodeErrorZ.mjs';
201 import { Result_NodeAnnouncementDecodeErrorZ } from '../structs/Result_NodeAnnouncementDecodeErrorZ.mjs';
202 import { Result_QueryShortChannelIdsDecodeErrorZ } from '../structs/Result_QueryShortChannelIdsDecodeErrorZ.mjs';
203 import { ReplyShortChannelIdsEnd } from '../structs/ReplyShortChannelIdsEnd.mjs';
204 import { Result_ReplyShortChannelIdsEndDecodeErrorZ } from '../structs/Result_ReplyShortChannelIdsEndDecodeErrorZ.mjs';
205 import { Result_QueryChannelRangeDecodeErrorZ } from '../structs/Result_QueryChannelRangeDecodeErrorZ.mjs';
206 import { Result_ReplyChannelRangeDecodeErrorZ } from '../structs/Result_ReplyChannelRangeDecodeErrorZ.mjs';
207 import { GossipTimestampFilter } from '../structs/GossipTimestampFilter.mjs';
208 import { Result_GossipTimestampFilterDecodeErrorZ } from '../structs/Result_GossipTimestampFilterDecodeErrorZ.mjs';
209 import { Result_DelayedPaymentOutputDescriptorDecodeErrorZ } from '../structs/Result_DelayedPaymentOutputDescriptorDecodeErrorZ.mjs';
210 import { Result_StaticPaymentOutputDescriptorDecodeErrorZ } from '../structs/Result_StaticPaymentOutputDescriptorDecodeErrorZ.mjs';
211 import { Result_SpendableOutputDescriptorDecodeErrorZ } from '../structs/Result_SpendableOutputDescriptorDecodeErrorZ.mjs';
212 import { Result_SignDecodeErrorZ } from '../structs/Result_SignDecodeErrorZ.mjs';
213 import { Result_RecoverableSignatureNoneZ } from '../structs/Result_RecoverableSignatureNoneZ.mjs';
214 import { Result_CVec_CVec_u8ZZNoneZ } from '../structs/Result_CVec_CVec_u8ZZNoneZ.mjs';
215 import { InMemorySigner } from '../structs/InMemorySigner.mjs';
216 import { Result_InMemorySignerDecodeErrorZ } from '../structs/Result_InMemorySignerDecodeErrorZ.mjs';
217 import { Result_TransactionNoneZ } from '../structs/Result_TransactionNoneZ.mjs';
218 import { WatchedOutput } from '../structs/WatchedOutput.mjs';
219 import { Filter, FilterInterface } from '../structs/Filter.mjs';
220 import { Option_FilterZ } from '../structs/Option_FilterZ.mjs';
221 import { LockedChannelMonitor } from '../structs/LockedChannelMonitor.mjs';
222 import { Result_LockedChannelMonitorNoneZ } from '../structs/Result_LockedChannelMonitorNoneZ.mjs';
223 import { APIError } from '../structs/APIError.mjs';
224 import { Result_NoneAPIErrorZ } from '../structs/Result_NoneAPIErrorZ.mjs';
225 import { Option_u16Z } from '../structs/Option_u16Z.mjs';
226 import { Result__u832APIErrorZ } from '../structs/Result__u832APIErrorZ.mjs';
227 import { PaymentSendFailure } from '../structs/PaymentSendFailure.mjs';
228 import { Result_PaymentIdPaymentSendFailureZ } from '../structs/Result_PaymentIdPaymentSendFailureZ.mjs';
229 import { Result_NonePaymentSendFailureZ } from '../structs/Result_NonePaymentSendFailureZ.mjs';
230 import { TwoTuple_PaymentHashPaymentIdZ } from '../structs/TwoTuple_PaymentHashPaymentIdZ.mjs';
231 import { Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ } from '../structs/Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.mjs';
232 import { TwoTuple_PaymentHashPaymentSecretZ } from '../structs/TwoTuple_PaymentHashPaymentSecretZ.mjs';
233 import { Result_C2Tuple_PaymentHashPaymentSecretZNoneZ } from '../structs/Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.mjs';
234 import { Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ } from '../structs/Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ.mjs';
235 import { Result_PaymentSecretNoneZ } from '../structs/Result_PaymentSecretNoneZ.mjs';
236 import { Result_PaymentSecretAPIErrorZ } from '../structs/Result_PaymentSecretAPIErrorZ.mjs';
237 import { Result_PaymentPreimageAPIErrorZ } from '../structs/Result_PaymentPreimageAPIErrorZ.mjs';
238 import { Watch, WatchInterface } from '../structs/Watch.mjs';
239 import { BroadcasterInterface, BroadcasterInterfaceInterface } from '../structs/BroadcasterInterface.mjs';
240 import { KeysInterface, KeysInterfaceInterface } from '../structs/KeysInterface.mjs';
241 import { FeeEstimator, FeeEstimatorInterface } from '../structs/FeeEstimator.mjs';
242 import { Record } from '../structs/Record.mjs';
243 import { Logger, LoggerInterface } from '../structs/Logger.mjs';
244 import { TwoTuple_BlockHashChannelManagerZ } from '../structs/TwoTuple_BlockHashChannelManagerZ.mjs';
245 import { Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ } from '../structs/Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.mjs';
246 import { MessageSendEventsProvider, MessageSendEventsProviderInterface } from '../structs/MessageSendEventsProvider.mjs';
247 import { EventHandler, EventHandlerInterface } from '../structs/EventHandler.mjs';
248 import { EventsProvider, EventsProviderInterface } from '../structs/EventsProvider.mjs';
249 import { ChannelHandshakeConfig } from '../structs/ChannelHandshakeConfig.mjs';
250 import { ChannelHandshakeLimits } from '../structs/ChannelHandshakeLimits.mjs';
251 import { UserConfig } from '../structs/UserConfig.mjs';
252 import { BestBlock } from '../structs/BestBlock.mjs';
253 import { Listen, ListenInterface } from '../structs/Listen.mjs';
254 import { Confirm, ConfirmInterface } from '../structs/Confirm.mjs';
255 import { MonitorUpdateId } from '../structs/MonitorUpdateId.mjs';
256 import { Persist, PersistInterface } from '../structs/Persist.mjs';
257 import { ChainMonitor } from '../structs/ChainMonitor.mjs';
258 import { KeysManager } from '../structs/KeysManager.mjs';
259 import { ChainParameters } from '../structs/ChainParameters.mjs';
260 import { CounterpartyForwardingInfo } from '../structs/CounterpartyForwardingInfo.mjs';
261 import { ChannelCounterparty } from '../structs/ChannelCounterparty.mjs';
262 import { ChannelMessageHandler, ChannelMessageHandlerInterface } from '../structs/ChannelMessageHandler.mjs';
263 import { ChannelManagerReadArgs } from '../structs/ChannelManagerReadArgs.mjs';
264 import { DataLossProtect } from '../structs/DataLossProtect.mjs';
265 import { RoutingMessageHandler, RoutingMessageHandlerInterface } from '../structs/RoutingMessageHandler.mjs';
266 import { CustomMessageReader, CustomMessageReaderInterface } from '../structs/CustomMessageReader.mjs';
267 import { CustomMessageHandler, CustomMessageHandlerInterface } from '../structs/CustomMessageHandler.mjs';
268 import { IgnoringMessageHandler } from '../structs/IgnoringMessageHandler.mjs';
269 import { ErroringMessageHandler } from '../structs/ErroringMessageHandler.mjs';
270 import { MessageHandler } from '../structs/MessageHandler.mjs';
271 import { SocketDescriptor, SocketDescriptorInterface } from '../structs/SocketDescriptor.mjs';
272 import { PeerManager } from '../structs/PeerManager.mjs';
273 import { DirectedChannelTransactionParameters } from '../structs/DirectedChannelTransactionParameters.mjs';
274 import { ReadOnlyNetworkGraph } from '../structs/ReadOnlyNetworkGraph.mjs';
275 import { NetGraphMsgHandler } from '../structs/NetGraphMsgHandler.mjs';
276 import { Score, ScoreInterface } from '../structs/Score.mjs';
277 import { LockableScore, LockableScoreInterface } from '../structs/LockableScore.mjs';
278 import { MultiThreadedLockableScore } from '../structs/MultiThreadedLockableScore.mjs';
279
280 import CommonBase from './CommonBase.mjs';
281 import * as bindings from '../bindings.mjs'
282
283
284 /**
285  * Manager which keeps track of a number of channels and sends messages to the appropriate
286  * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
287  * 
288  * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
289  * to individual Channels.
290  * 
291  * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
292  * all peers during write/read (though does not modify this instance, only the instance being
293  * serialized). This will result in any channels which have not yet exchanged funding_created (ie
294  * called funding_transaction_generated for outbound channels).
295  * 
296  * Note that you can be a bit lazier about writing out ChannelManager than you can be with
297  * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
298  * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
299  * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
300  * the serialization process). If the deserialized version is out-of-date compared to the
301  * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
302  * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
303  * 
304  * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which
305  * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
306  * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
307  * block_connected() to step towards your best block) upon deserialization before using the
308  * object!
309  * 
310  * Note that ChannelManager is responsible for tracking liveness of its channels and generating
311  * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
312  * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
313  * offline for a full minute. In order to track this, you must call
314  * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect.
315  * 
316  * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
317  * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
318  * essentially you should default to using a SimpleRefChannelManager, and use a
319  * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
320  * you're using lightning-net-tokio.
321  */
322 export class ChannelManager extends CommonBase {
323         /* @internal */
324         public constructor(_dummy: object, ptr: number) {
325                 super(ptr, bindings.ChannelManager_free);
326         }
327
328         /**
329          * Constructs a new ChannelManager to hold several channels and route between them.
330          * 
331          * This is the main \"logic hub\" for all channel-related actions, and implements
332          * ChannelMessageHandler.
333          * 
334          * Non-proportional fees are fixed according to our risk using the provided fee estimator.
335          * 
336          * panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
337          * 
338          * Users need to notify the new ChannelManager when a new block is connected or
339          * disconnected using its `block_connected` and `block_disconnected` methods, starting
340          * from after `params.latest_hash`.
341          */
342         public static constructor_new(fee_est: FeeEstimator, chain_monitor: Watch, tx_broadcaster: BroadcasterInterface, logger: Logger, keys_manager: KeysInterface, config: UserConfig, params: ChainParameters): ChannelManager {
343                 const ret: number = bindings.ChannelManager_new(fee_est == null ? 0 : CommonBase.get_ptr_of(fee_est), chain_monitor == null ? 0 : CommonBase.get_ptr_of(chain_monitor), tx_broadcaster == null ? 0 : CommonBase.get_ptr_of(tx_broadcaster), logger == null ? 0 : CommonBase.get_ptr_of(logger), keys_manager == null ? 0 : CommonBase.get_ptr_of(keys_manager), config == null ? 0 : CommonBase.get_ptr_of(config) & ~1, params == null ? 0 : CommonBase.get_ptr_of(params) & ~1);
344                 const ret_hu_conv: ChannelManager = new ChannelManager(null, ret);
345                 CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
346                 CommonBase.add_ref_from(ret_hu_conv, fee_est);
347                 CommonBase.add_ref_from(ret_hu_conv, chain_monitor);
348                 CommonBase.add_ref_from(ret_hu_conv, tx_broadcaster);
349                 CommonBase.add_ref_from(ret_hu_conv, logger);
350                 CommonBase.add_ref_from(ret_hu_conv, keys_manager);
351                 return ret_hu_conv;
352         }
353
354         /**
355          * Gets the current configuration applied to all new channels,  as
356          */
357         public get_current_default_configuration(): UserConfig {
358                 const ret: number = bindings.ChannelManager_get_current_default_configuration(this.ptr);
359                 const ret_hu_conv: UserConfig = new UserConfig(null, ret);
360                 CommonBase.add_ref_from(ret_hu_conv, this);
361                 return ret_hu_conv;
362         }
363
364         /**
365          * Creates a new outbound channel to the given remote node and with the given value.
366          * 
367          * `user_channel_id` will be provided back as in
368          * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
369          * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to 0
370          * for inbound channels, so you may wish to avoid using 0 for `user_channel_id` here.
371          * `user_channel_id` has no meaning inside of LDK, it is simply copied to events and otherwise
372          * ignored.
373          * 
374          * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
375          * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
376          * 
377          * Note that we do not check if you are currently connected to the given peer. If no
378          * connection is available, the outbound `open_channel` message may fail to send, resulting in
379          * the channel eventually being silently forgotten (dropped on reload).
380          * 
381          * Returns the new Channel's temporary `channel_id`. This ID will appear as
382          * [`Event::FundingGenerationReady::temporary_channel_id`] and in
383          * [`ChannelDetails::channel_id`] until after
384          * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
385          * one derived from the funding transaction's TXID. If the counterparty rejects the channel
386          * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
387          * 
388          * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
389          * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
390          * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
391          * 
392          * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
393          */
394         public create_channel(their_network_key: Uint8Array, channel_value_satoshis: bigint, push_msat: bigint, user_channel_id: bigint, override_config: UserConfig): Result__u832APIErrorZ {
395                 const ret: number = bindings.ChannelManager_create_channel(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(their_network_key, 33)), channel_value_satoshis, push_msat, user_channel_id, override_config == null ? 0 : CommonBase.get_ptr_of(override_config) & ~1);
396                 const ret_hu_conv: Result__u832APIErrorZ = Result__u832APIErrorZ.constr_from_ptr(ret);
397                 return ret_hu_conv;
398         }
399
400         /**
401          * Gets the list of open channels, in random order. See ChannelDetail field documentation for
402          * more information.
403          */
404         public list_channels(): ChannelDetails[] {
405                 const ret: number = bindings.ChannelManager_list_channels(this.ptr);
406                 const ret_conv_16_len: number = bindings.getArrayLength(ret);
407                 const ret_conv_16_arr: ChannelDetails[] = new Array(ret_conv_16_len).fill(null);
408                 for (var q = 0; q < ret_conv_16_len; q++) {
409                         const ret_conv_16: number = bindings.getU32ArrayElem(ret, q);
410                         const ret_conv_16_hu_conv: ChannelDetails = new ChannelDetails(null, ret_conv_16);
411                         CommonBase.add_ref_from(ret_conv_16_hu_conv, this);
412                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
413                 }
414                 bindings.freeWasmMemory(ret)
415                 return ret_conv_16_arr;
416         }
417
418         /**
419          * Gets the list of usable channels, in random order. Useful as an argument to
420          * get_route to ensure non-announced channels are used.
421          * 
422          * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
423          * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
424          * are.
425          */
426         public list_usable_channels(): ChannelDetails[] {
427                 const ret: number = bindings.ChannelManager_list_usable_channels(this.ptr);
428                 const ret_conv_16_len: number = bindings.getArrayLength(ret);
429                 const ret_conv_16_arr: ChannelDetails[] = new Array(ret_conv_16_len).fill(null);
430                 for (var q = 0; q < ret_conv_16_len; q++) {
431                         const ret_conv_16: number = bindings.getU32ArrayElem(ret, q);
432                         const ret_conv_16_hu_conv: ChannelDetails = new ChannelDetails(null, ret_conv_16);
433                         CommonBase.add_ref_from(ret_conv_16_hu_conv, this);
434                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
435                 }
436                 bindings.freeWasmMemory(ret)
437                 return ret_conv_16_arr;
438         }
439
440         /**
441          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
442          * will be accepted on the given channel, and after additional timeout/the closing of all
443          * pending HTLCs, the channel will be closed on chain.
444          * 
445          * If we are the channel initiator, we will pay between our [`Background`] and
446          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
447          * estimate.
448          * If our counterparty is the channel initiator, we will require a channel closing
449          * transaction feerate of at least our [`Background`] feerate or the feerate which
450          * would appear on a force-closure transaction, whichever is lower. We will allow our
451          * counterparty to pay as much fee as they'd like, however.
452          * 
453          * May generate a SendShutdown message event on success, which should be relayed.
454          * 
455          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
456          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
457          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
458          */
459         public close_channel(channel_id: Uint8Array): Result_NoneAPIErrorZ {
460                 const ret: number = bindings.ChannelManager_close_channel(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(channel_id, 32)));
461                 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
462                 return ret_hu_conv;
463         }
464
465         /**
466          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
467          * will be accepted on the given channel, and after additional timeout/the closing of all
468          * pending HTLCs, the channel will be closed on chain.
469          * 
470          * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
471          * the channel being closed or not:
472          * If we are the channel initiator, we will pay at least this feerate on the closing
473          * transaction. The upper-bound is set by
474          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
475          * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
476          * If our counterparty is the channel initiator, we will refuse to accept a channel closure
477          * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
478          * will appear on a force-closure transaction, whichever is lower).
479          * 
480          * May generate a SendShutdown message event on success, which should be relayed.
481          * 
482          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
483          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
484          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
485          */
486         public close_channel_with_target_feerate(channel_id: Uint8Array, target_feerate_sats_per_1000_weight: number): Result_NoneAPIErrorZ {
487                 const ret: number = bindings.ChannelManager_close_channel_with_target_feerate(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(channel_id, 32)), target_feerate_sats_per_1000_weight);
488                 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
489                 return ret_hu_conv;
490         }
491
492         /**
493          * Force closes a channel, immediately broadcasting the latest local commitment transaction to
494          * the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager.
495          */
496         public force_close_channel(channel_id: Uint8Array): Result_NoneAPIErrorZ {
497                 const ret: number = bindings.ChannelManager_force_close_channel(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(channel_id, 32)));
498                 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
499                 return ret_hu_conv;
500         }
501
502         /**
503          * Force close all channels, immediately broadcasting the latest local commitment transaction
504          * for each to the chain and rejecting new HTLCs on each.
505          */
506         public force_close_all_channels(): void {
507                 bindings.ChannelManager_force_close_all_channels(this.ptr);
508         }
509
510         /**
511          * Sends a payment along a given route.
512          * 
513          * Value parameters are provided via the last hop in route, see documentation for RouteHop
514          * fields for more info.
515          * 
516          * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
517          * payment), we don't do anything to stop you! We always try to ensure that if the provided
518          * next hop knows the preimage to payment_hash they can claim an additional amount as
519          * specified in the last hop in the route! Thus, you should probably do your own
520          * payment_preimage tracking (which you should already be doing as they represent \"proof of
521          * payment\") and prevent double-sends yourself.
522          * 
523          * May generate SendHTLCs message(s) event on success, which should be relayed.
524          * 
525          * Each path may have a different return value, and PaymentSendValue may return a Vec with
526          * each entry matching the corresponding-index entry in the route paths, see
527          * PaymentSendFailure for more info.
528          * 
529          * In general, a path may raise:
530          * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
531          * node public key) is specified.
532          * APIError::ChannelUnavailable if the next-hop channel is not available for updates
533          * (including due to previous monitor update failure or new permanent monitor update
534          * failure).
535          * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
536          * relevant updates.
537          * 
538          * Note that depending on the type of the PaymentSendFailure the HTLC may have been
539          * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
540          * different route unless you intend to pay twice!
541          * 
542          * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
543          * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
544          * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
545          * must not contain multiple paths as multi-path payments require a recipient-provided
546          * payment_secret.
547          * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
548          * bit set (either as required or as available). If multiple paths are present in the Route,
549          * we assume the invoice had the basic_mpp feature set.
550          * 
551          * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
552          */
553         public send_payment(route: Route, payment_hash: Uint8Array, payment_secret: Uint8Array): Result_PaymentIdPaymentSendFailureZ {
554                 const ret: number = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : CommonBase.get_ptr_of(route) & ~1, bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), bindings.encodeUint8Array(bindings.check_arr_len(payment_secret, 32)));
555                 const ret_hu_conv: Result_PaymentIdPaymentSendFailureZ = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
556                 CommonBase.add_ref_from(this, route);
557                 return ret_hu_conv;
558         }
559
560         /**
561          * Retries a payment along the given [`Route`].
562          * 
563          * Errors returned are a superset of those returned from [`send_payment`], so see
564          * [`send_payment`] documentation for more details on errors. This method will also error if the
565          * retry amount puts the payment more than 10% over the payment's total amount, if the payment
566          * for the given `payment_id` cannot be found (likely due to timeout or success), or if
567          * further retries have been disabled with [`abandon_payment`].
568          * 
569          * [`send_payment`]: [`ChannelManager::send_payment`]
570          * [`abandon_payment`]: [`ChannelManager::abandon_payment`]
571          */
572         public retry_payment(route: Route, payment_id: Uint8Array): Result_NonePaymentSendFailureZ {
573                 const ret: number = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : CommonBase.get_ptr_of(route) & ~1, bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)));
574                 const ret_hu_conv: Result_NonePaymentSendFailureZ = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
575                 CommonBase.add_ref_from(this, route);
576                 return ret_hu_conv;
577         }
578
579         /**
580          * Signals that no further retries for the given payment will occur.
581          * 
582          * After this method returns, any future calls to [`retry_payment`] for the given `payment_id`
583          * will fail with [`PaymentSendFailure::ParameterError`]. If no such event has been generated,
584          * an [`Event::PaymentFailed`] event will be generated as soon as there are no remaining
585          * pending HTLCs for this payment.
586          * 
587          * Note that calling this method does *not* prevent a payment from succeeding. You must still
588          * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
589          * determine the ultimate status of a payment.
590          * 
591          * [`retry_payment`]: Self::retry_payment
592          * [`Event::PaymentFailed`]: events::Event::PaymentFailed
593          * [`Event::PaymentSent`]: events::Event::PaymentSent
594          */
595         public abandon_payment(payment_id: Uint8Array): void {
596                 bindings.ChannelManager_abandon_payment(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)));
597         }
598
599         /**
600          * Send a spontaneous payment, which is a payment that does not require the recipient to have
601          * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
602          * the preimage, it must be a cryptographically secure random value that no intermediate node
603          * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
604          * never reach the recipient.
605          * 
606          * See [`send_payment`] documentation for more details on the return value of this function.
607          * 
608          * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
609          * [`send_payment`] for more information about the risks of duplicate preimage usage.
610          * 
611          * Note that `route` must have exactly one path.
612          * 
613          * [`send_payment`]: Self::send_payment
614          * 
615          * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
616          */
617         public send_spontaneous_payment(route: Route, payment_preimage: Uint8Array): Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ {
618                 const ret: number = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route == null ? 0 : CommonBase.get_ptr_of(route) & ~1, bindings.encodeUint8Array(bindings.check_arr_len(payment_preimage, 32)));
619                 const ret_hu_conv: Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
620                 CommonBase.add_ref_from(this, route);
621                 return ret_hu_conv;
622         }
623
624         /**
625          * Call this upon creation of a funding transaction for the given channel.
626          * 
627          * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
628          * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
629          * 
630          * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
631          * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
632          * 
633          * May panic if the output found in the funding transaction is duplicative with some other
634          * channel (note that this should be trivially prevented by using unique funding transaction
635          * keys per-channel).
636          * 
637          * Do NOT broadcast the funding transaction yourself. When we have safely received our
638          * counterparty's signature the funding transaction will automatically be broadcast via the
639          * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
640          * 
641          * Note that this includes RBF or similar transaction replacement strategies - lightning does
642          * not currently support replacing a funding transaction on an existing channel. Instead,
643          * create a new channel with a conflicting funding transaction.
644          * 
645          * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
646          * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed
647          */
648         public funding_transaction_generated(temporary_channel_id: Uint8Array, funding_transaction: Uint8Array): Result_NoneAPIErrorZ {
649                 const ret: number = bindings.ChannelManager_funding_transaction_generated(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(temporary_channel_id, 32)), bindings.encodeUint8Array(funding_transaction));
650                 const ret_hu_conv: Result_NoneAPIErrorZ = Result_NoneAPIErrorZ.constr_from_ptr(ret);
651                 return ret_hu_conv;
652         }
653
654         /**
655          * Regenerates channel_announcements and generates a signed node_announcement from the given
656          * arguments, providing them in corresponding events via
657          * [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
658          * on-chain. This effectively re-broadcasts all channel announcements and sends our node
659          * announcement to ensure that the lightning P2P network is aware of the channels we have and
660          * our network addresses.
661          * 
662          * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
663          * node to humans. They carry no in-protocol meaning.
664          * 
665          * `addresses` represent the set (possibly empty) of socket addresses on which this node
666          * accepts incoming connections. These will be included in the node_announcement, publicly
667          * tying these addresses together and to this node. If you wish to preserve user privacy,
668          * addresses should likely contain only Tor Onion addresses.
669          * 
670          * Panics if `addresses` is absurdly large (more than 500).
671          * 
672          * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
673          */
674         public broadcast_node_announcement(rgb: Uint8Array, alias: Uint8Array, addresses: NetAddress[]): void {
675                 bindings.ChannelManager_broadcast_node_announcement(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(rgb, 3)), bindings.encodeUint8Array(bindings.check_arr_len(alias, 32)), bindings.encodeUint32Array(addresses != null ? addresses.map(addresses_conv_12 => CommonBase.get_ptr_of(addresses_conv_12)) : null));
676         }
677
678         /**
679          * Processes HTLCs which are pending waiting on random forward delay.
680          * 
681          * Should only really ever be called in response to a PendingHTLCsForwardable event.
682          * Will likely generate further events.
683          */
684         public process_pending_htlc_forwards(): void {
685                 bindings.ChannelManager_process_pending_htlc_forwards(this.ptr);
686         }
687
688         /**
689          * Performs actions which should happen on startup and roughly once per minute thereafter.
690          * 
691          * This currently includes:
692          * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
693          * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
694          * than a minute, informing the network that they should no longer attempt to route over
695          * the channel.
696          * 
697          * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
698          * estimate fetches.
699          */
700         public timer_tick_occurred(): void {
701                 bindings.ChannelManager_timer_tick_occurred(this.ptr);
702         }
703
704         /**
705          * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
706          * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources
707          * along the path (including in our own channel on which we received it).
708          * Returns false if no payment was found to fail backwards, true if the process of failing the
709          * HTLC backwards has been started.
710          */
711         public fail_htlc_backwards(payment_hash: Uint8Array): boolean {
712                 const ret: boolean = bindings.ChannelManager_fail_htlc_backwards(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)));
713                 return ret;
714         }
715
716         /**
717          * Provides a payment preimage in response to [`Event::PaymentReceived`], generating any
718          * [`MessageSendEvent`]s needed to claim the payment.
719          * 
720          * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
721          * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived`
722          * event matches your expectation. If you fail to do so and call this method, you may provide
723          * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
724          * 
725          * Returns whether any HTLCs were claimed, and thus if any new [`MessageSendEvent`]s are now
726          * pending for processing via [`get_and_clear_pending_msg_events`].
727          * 
728          * [`Event::PaymentReceived`]: crate::util::events::Event::PaymentReceived
729          * [`create_inbound_payment`]: Self::create_inbound_payment
730          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
731          * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
732          */
733         public claim_funds(payment_preimage: Uint8Array): boolean {
734                 const ret: boolean = bindings.ChannelManager_claim_funds(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_preimage, 32)));
735                 return ret;
736         }
737
738         /**
739          * Gets the node_id held by this ChannelManager
740          */
741         public get_our_node_id(): Uint8Array {
742                 const ret: number = bindings.ChannelManager_get_our_node_id(this.ptr);
743                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
744                 return ret_conv;
745         }
746
747         /**
748          * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
749          * to pay us.
750          * 
751          * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
752          * [`PaymentHash`] and [`PaymentPreimage`] for you.
753          * 
754          * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which
755          * will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be
756          * passed directly to [`claim_funds`].
757          * 
758          * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
759          * 
760          * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
761          * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
762          * 
763          * # Note
764          * 
765          * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
766          * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
767          * 
768          * Errors if `min_value_msat` is greater than total bitcoin supply.
769          * 
770          * [`claim_funds`]: Self::claim_funds
771          * [`PaymentReceived`]: events::Event::PaymentReceived
772          * [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage
773          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
774          */
775         public create_inbound_payment(min_value_msat: Option_u64Z, invoice_expiry_delta_secs: number): Result_C2Tuple_PaymentHashPaymentSecretZNoneZ {
776                 const ret: number = bindings.ChannelManager_create_inbound_payment(this.ptr, CommonBase.get_ptr_of(min_value_msat), invoice_expiry_delta_secs);
777                 const ret_hu_conv: Result_C2Tuple_PaymentHashPaymentSecretZNoneZ = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret);
778                 return ret_hu_conv;
779         }
780
781         /**
782          * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
783          * serialized state with LDK node(s) running 0.0.103 and earlier.
784          * 
785          * # Note
786          * This method is deprecated and will be removed soon.
787          * 
788          * [`create_inbound_payment`]: Self::create_inbound_payment
789          */
790         public create_inbound_payment_legacy(min_value_msat: Option_u64Z, invoice_expiry_delta_secs: number): Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ {
791                 const ret: number = bindings.ChannelManager_create_inbound_payment_legacy(this.ptr, CommonBase.get_ptr_of(min_value_msat), invoice_expiry_delta_secs);
792                 const ret_hu_conv: Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ = Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ.constr_from_ptr(ret);
793                 return ret_hu_conv;
794         }
795
796         /**
797          * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
798          * stored external to LDK.
799          * 
800          * A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a
801          * payment secret fetched via this method or [`create_inbound_payment`], and which is at least
802          * the `min_value_msat` provided here, if one is provided.
803          * 
804          * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
805          * note that LDK will not stop you from registering duplicate payment hashes for inbound
806          * payments.
807          * 
808          * `min_value_msat` should be set if the invoice being generated contains a value. Any payment
809          * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
810          * before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the
811          * sender \"proof-of-payment\" unless they have paid the required amount.
812          * 
813          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
814          * in excess of the current time. This should roughly match the expiry time set in the invoice.
815          * After this many seconds, we will remove the inbound payment, resulting in any attempts to
816          * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
817          * invoices when no timeout is set.
818          * 
819          * Note that we use block header time to time-out pending inbound payments (with some margin
820          * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
821          * accept a payment and generate a [`PaymentReceived`] event for some time after the expiry.
822          * If you need exact expiry semantics, you should enforce them upon receipt of
823          * [`PaymentReceived`].
824          * 
825          * May panic if `invoice_expiry_delta_secs` is greater than one year.
826          * 
827          * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
828          * set to at least [`MIN_FINAL_CLTV_EXPIRY`].
829          * 
830          * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
831          * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
832          * 
833          * # Note
834          * 
835          * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
836          * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
837          * 
838          * Errors if `min_value_msat` is greater than total bitcoin supply.
839          * 
840          * [`create_inbound_payment`]: Self::create_inbound_payment
841          * [`PaymentReceived`]: events::Event::PaymentReceived
842          */
843         public create_inbound_payment_for_hash(payment_hash: Uint8Array, min_value_msat: Option_u64Z, invoice_expiry_delta_secs: number): Result_PaymentSecretNoneZ {
844                 const ret: number = 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);
845                 const ret_hu_conv: Result_PaymentSecretNoneZ = Result_PaymentSecretNoneZ.constr_from_ptr(ret);
846                 return ret_hu_conv;
847         }
848
849         /**
850          * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
851          * serialized state with LDK node(s) running 0.0.103 and earlier.
852          * 
853          * # Note
854          * This method is deprecated and will be removed soon.
855          * 
856          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
857          */
858         public create_inbound_payment_for_hash_legacy(payment_hash: Uint8Array, min_value_msat: Option_u64Z, invoice_expiry_delta_secs: number): Result_PaymentSecretAPIErrorZ {
859                 const ret: number = bindings.ChannelManager_create_inbound_payment_for_hash_legacy(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), CommonBase.get_ptr_of(min_value_msat), invoice_expiry_delta_secs);
860                 const ret_hu_conv: Result_PaymentSecretAPIErrorZ = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
861                 return ret_hu_conv;
862         }
863
864         /**
865          * Gets an LDK-generated payment preimage from a payment hash and payment secret that were
866          * previously returned from [`create_inbound_payment`].
867          * 
868          * [`create_inbound_payment`]: Self::create_inbound_payment
869          */
870         public get_payment_preimage(payment_hash: Uint8Array, payment_secret: Uint8Array): Result_PaymentPreimageAPIErrorZ {
871                 const ret: number = 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)));
872                 const ret_hu_conv: Result_PaymentPreimageAPIErrorZ = Result_PaymentPreimageAPIErrorZ.constr_from_ptr(ret);
873                 return ret_hu_conv;
874         }
875
876         /**
877          * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
878          * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
879          */
880         public as_MessageSendEventsProvider(): MessageSendEventsProvider {
881                 const ret: number = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
882                 const ret_hu_conv: MessageSendEventsProvider = new MessageSendEventsProvider(null, ret);
883                 CommonBase.add_ref_from(ret_hu_conv, this);
884                 return ret_hu_conv;
885         }
886
887         /**
888          * Constructs a new EventsProvider which calls the relevant methods on this_arg.
889          * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
890          */
891         public as_EventsProvider(): EventsProvider {
892                 const ret: number = bindings.ChannelManager_as_EventsProvider(this.ptr);
893                 const ret_hu_conv: EventsProvider = new EventsProvider(null, ret);
894                 CommonBase.add_ref_from(ret_hu_conv, this);
895                 return ret_hu_conv;
896         }
897
898         /**
899          * Constructs a new Listen which calls the relevant methods on this_arg.
900          * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
901          */
902         public as_Listen(): Listen {
903                 const ret: number = bindings.ChannelManager_as_Listen(this.ptr);
904                 const ret_hu_conv: Listen = new Listen(null, ret);
905                 CommonBase.add_ref_from(ret_hu_conv, this);
906                 return ret_hu_conv;
907         }
908
909         /**
910          * Constructs a new Confirm which calls the relevant methods on this_arg.
911          * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
912          */
913         public as_Confirm(): Confirm {
914                 const ret: number = bindings.ChannelManager_as_Confirm(this.ptr);
915                 const ret_hu_conv: Confirm = new Confirm(null, ret);
916                 CommonBase.add_ref_from(ret_hu_conv, this);
917                 return ret_hu_conv;
918         }
919
920         /**
921          * Blocks until ChannelManager needs to be persisted. Only one listener on
922          * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
923          * up.
924          */
925         public await_persistable_update(): void {
926                 bindings.ChannelManager_await_persistable_update(this.ptr);
927         }
928
929         /**
930          * Gets the latest best block which was connected either via the [`chain::Listen`] or
931          * [`chain::Confirm`] interfaces.
932          */
933         public current_best_block(): BestBlock {
934                 const ret: number = bindings.ChannelManager_current_best_block(this.ptr);
935                 const ret_hu_conv: BestBlock = new BestBlock(null, ret);
936                 CommonBase.add_ref_from(ret_hu_conv, this);
937                 return ret_hu_conv;
938         }
939
940         /**
941          * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
942          * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
943          */
944         public as_ChannelMessageHandler(): ChannelMessageHandler {
945                 const ret: number = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
946                 const ret_hu_conv: ChannelMessageHandler = new ChannelMessageHandler(null, ret);
947                 CommonBase.add_ref_from(ret_hu_conv, this);
948                 return ret_hu_conv;
949         }
950
951         /**
952          * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
953          */
954         public write(): Uint8Array {
955                 const ret: number = bindings.ChannelManager_write(this.ptr);
956                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
957                 return ret_conv;
958         }
959
960 }