8cc99d9a495bce7da8705f982cc0de4e449aa3f8
[ldk-java] / ts / structs / UtilMethods.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 { CreationError } from '../enums/CreationError.mjs';
7 import { Currency } from '../enums/Currency.mjs';
8 import { IOError } from '../enums/IOError.mjs';
9 import { Level } from '../enums/Level.mjs';
10 import { Network } from '../enums/Network.mjs';
11 import { Recipient } from '../enums/Recipient.mjs';
12 import { Secp256k1Error } from '../enums/Secp256k1Error.mjs';
13 import { SemanticError } from '../enums/SemanticError.mjs';
14 import { SiPrefix } from '../enums/SiPrefix.mjs';
15 import { Bech32Error } from '../structs/Bech32Error.mjs';
16 import { Result_NoneNoneZ } from '../structs/Result_NoneNoneZ.mjs';
17 import { CounterpartyCommitmentSecrets } from '../structs/CounterpartyCommitmentSecrets.mjs';
18 import { DecodeError } from '../structs/DecodeError.mjs';
19 import { Result_CounterpartyCommitmentSecretsDecodeErrorZ } from '../structs/Result_CounterpartyCommitmentSecretsDecodeErrorZ.mjs';
20 import { Result_SecretKeyErrorZ } from '../structs/Result_SecretKeyErrorZ.mjs';
21 import { Result_PublicKeyErrorZ } from '../structs/Result_PublicKeyErrorZ.mjs';
22 import { TxCreationKeys } from '../structs/TxCreationKeys.mjs';
23 import { Result_TxCreationKeysDecodeErrorZ } from '../structs/Result_TxCreationKeysDecodeErrorZ.mjs';
24 import { ChannelPublicKeys } from '../structs/ChannelPublicKeys.mjs';
25 import { Result_ChannelPublicKeysDecodeErrorZ } from '../structs/Result_ChannelPublicKeysDecodeErrorZ.mjs';
26 import { Result_TxCreationKeysErrorZ } from '../structs/Result_TxCreationKeysErrorZ.mjs';
27 import { Option_u32Z } from '../structs/Option_u32Z.mjs';
28 import { HTLCOutputInCommitment } from '../structs/HTLCOutputInCommitment.mjs';
29 import { Result_HTLCOutputInCommitmentDecodeErrorZ } from '../structs/Result_HTLCOutputInCommitmentDecodeErrorZ.mjs';
30 import { CounterpartyChannelTransactionParameters } from '../structs/CounterpartyChannelTransactionParameters.mjs';
31 import { Result_CounterpartyChannelTransactionParametersDecodeErrorZ } from '../structs/Result_CounterpartyChannelTransactionParametersDecodeErrorZ.mjs';
32 import { ChannelTransactionParameters } from '../structs/ChannelTransactionParameters.mjs';
33 import { Result_ChannelTransactionParametersDecodeErrorZ } from '../structs/Result_ChannelTransactionParametersDecodeErrorZ.mjs';
34 import { HolderCommitmentTransaction } from '../structs/HolderCommitmentTransaction.mjs';
35 import { Result_HolderCommitmentTransactionDecodeErrorZ } from '../structs/Result_HolderCommitmentTransactionDecodeErrorZ.mjs';
36 import { BuiltCommitmentTransaction } from '../structs/BuiltCommitmentTransaction.mjs';
37 import { Result_BuiltCommitmentTransactionDecodeErrorZ } from '../structs/Result_BuiltCommitmentTransactionDecodeErrorZ.mjs';
38 import { TrustedClosingTransaction } from '../structs/TrustedClosingTransaction.mjs';
39 import { Result_TrustedClosingTransactionNoneZ } from '../structs/Result_TrustedClosingTransactionNoneZ.mjs';
40 import { CommitmentTransaction } from '../structs/CommitmentTransaction.mjs';
41 import { Result_CommitmentTransactionDecodeErrorZ } from '../structs/Result_CommitmentTransactionDecodeErrorZ.mjs';
42 import { TrustedCommitmentTransaction } from '../structs/TrustedCommitmentTransaction.mjs';
43 import { Result_TrustedCommitmentTransactionNoneZ } from '../structs/Result_TrustedCommitmentTransactionNoneZ.mjs';
44 import { Result_CVec_SignatureZNoneZ } from '../structs/Result_CVec_SignatureZNoneZ.mjs';
45 import { ShutdownScript } from '../structs/ShutdownScript.mjs';
46 import { Result_ShutdownScriptDecodeErrorZ } from '../structs/Result_ShutdownScriptDecodeErrorZ.mjs';
47 import { InvalidShutdownScript } from '../structs/InvalidShutdownScript.mjs';
48 import { Result_ShutdownScriptInvalidShutdownScriptZ } from '../structs/Result_ShutdownScriptInvalidShutdownScriptZ.mjs';
49 import { RouteHop } from '../structs/RouteHop.mjs';
50 import { Result_RouteHopDecodeErrorZ } from '../structs/Result_RouteHopDecodeErrorZ.mjs';
51 import { Route } from '../structs/Route.mjs';
52 import { Result_RouteDecodeErrorZ } from '../structs/Result_RouteDecodeErrorZ.mjs';
53 import { RouteParameters } from '../structs/RouteParameters.mjs';
54 import { Result_RouteParametersDecodeErrorZ } from '../structs/Result_RouteParametersDecodeErrorZ.mjs';
55 import { RouteHint } from '../structs/RouteHint.mjs';
56 import { Option_u64Z } from '../structs/Option_u64Z.mjs';
57 import { PaymentParameters } from '../structs/PaymentParameters.mjs';
58 import { Result_PaymentParametersDecodeErrorZ } from '../structs/Result_PaymentParametersDecodeErrorZ.mjs';
59 import { RouteHintHop } from '../structs/RouteHintHop.mjs';
60 import { Result_RouteHintDecodeErrorZ } from '../structs/Result_RouteHintDecodeErrorZ.mjs';
61 import { Result_RouteHintHopDecodeErrorZ } from '../structs/Result_RouteHintHopDecodeErrorZ.mjs';
62 import { ChannelDetails } from '../structs/ChannelDetails.mjs';
63 import { LightningError } from '../structs/LightningError.mjs';
64 import { Result_RouteLightningErrorZ } from '../structs/Result_RouteLightningErrorZ.mjs';
65 import { PaymentPurpose } from '../structs/PaymentPurpose.mjs';
66 import { Result_PaymentPurposeDecodeErrorZ } from '../structs/Result_PaymentPurposeDecodeErrorZ.mjs';
67 import { ClosureReason } from '../structs/ClosureReason.mjs';
68 import { Option_ClosureReasonZ } from '../structs/Option_ClosureReasonZ.mjs';
69 import { Result_COption_ClosureReasonZDecodeErrorZ } from '../structs/Result_COption_ClosureReasonZDecodeErrorZ.mjs';
70 import { ChannelUpdate } from '../structs/ChannelUpdate.mjs';
71 import { NetworkUpdate } from '../structs/NetworkUpdate.mjs';
72 import { Option_NetworkUpdateZ } from '../structs/Option_NetworkUpdateZ.mjs';
73 import { OutPoint } from '../structs/OutPoint.mjs';
74 import { DelayedPaymentOutputDescriptor } from '../structs/DelayedPaymentOutputDescriptor.mjs';
75 import { StaticPaymentOutputDescriptor } from '../structs/StaticPaymentOutputDescriptor.mjs';
76 import { SpendableOutputDescriptor } from '../structs/SpendableOutputDescriptor.mjs';
77 import { ChannelTypeFeatures } from '../structs/ChannelTypeFeatures.mjs';
78 import { Event } from '../structs/Event.mjs';
79 import { Option_EventZ } from '../structs/Option_EventZ.mjs';
80 import { Result_COption_EventZDecodeErrorZ } from '../structs/Result_COption_EventZDecodeErrorZ.mjs';
81 import { AcceptChannel } from '../structs/AcceptChannel.mjs';
82 import { OpenChannel } from '../structs/OpenChannel.mjs';
83 import { FundingCreated } from '../structs/FundingCreated.mjs';
84 import { FundingSigned } from '../structs/FundingSigned.mjs';
85 import { ChannelReady } from '../structs/ChannelReady.mjs';
86 import { AnnouncementSignatures } from '../structs/AnnouncementSignatures.mjs';
87 import { CommitmentUpdate } from '../structs/CommitmentUpdate.mjs';
88 import { RevokeAndACK } from '../structs/RevokeAndACK.mjs';
89 import { ClosingSigned } from '../structs/ClosingSigned.mjs';
90 import { Shutdown } from '../structs/Shutdown.mjs';
91 import { ChannelReestablish } from '../structs/ChannelReestablish.mjs';
92 import { ChannelAnnouncement } from '../structs/ChannelAnnouncement.mjs';
93 import { NodeAnnouncement } from '../structs/NodeAnnouncement.mjs';
94 import { ErrorMessage } from '../structs/ErrorMessage.mjs';
95 import { WarningMessage } from '../structs/WarningMessage.mjs';
96 import { ErrorAction } from '../structs/ErrorAction.mjs';
97 import { QueryChannelRange } from '../structs/QueryChannelRange.mjs';
98 import { QueryShortChannelIds } from '../structs/QueryShortChannelIds.mjs';
99 import { ReplyChannelRange } from '../structs/ReplyChannelRange.mjs';
100 import { GossipTimestampFilter } from '../structs/GossipTimestampFilter.mjs';
101 import { MessageSendEvent } from '../structs/MessageSendEvent.mjs';
102 import { Result_TxOutAccessErrorZ } from '../structs/Result_TxOutAccessErrorZ.mjs';
103 import { TwoTuple_usizeTransactionZ } from '../structs/TwoTuple_usizeTransactionZ.mjs';
104 import { Result_NoneChannelMonitorUpdateErrZ } from '../structs/Result_NoneChannelMonitorUpdateErrZ.mjs';
105 import { HTLCUpdate } from '../structs/HTLCUpdate.mjs';
106 import { MonitorEvent } from '../structs/MonitorEvent.mjs';
107 import { TwoTuple_OutPointCVec_MonitorEventZZ } from '../structs/TwoTuple_OutPointCVec_MonitorEventZZ.mjs';
108 import { Option_C2Tuple_usizeTransactionZZ } from '../structs/Option_C2Tuple_usizeTransactionZZ.mjs';
109 import { FixedPenaltyScorer } from '../structs/FixedPenaltyScorer.mjs';
110 import { Result_FixedPenaltyScorerDecodeErrorZ } from '../structs/Result_FixedPenaltyScorerDecodeErrorZ.mjs';
111 import { Record } from '../structs/Record.mjs';
112 import { Logger, LoggerInterface } from '../structs/Logger.mjs';
113 import { NetworkGraph } from '../structs/NetworkGraph.mjs';
114 import { ProbabilisticScorer } from '../structs/ProbabilisticScorer.mjs';
115 import { Result_ProbabilisticScorerDecodeErrorZ } from '../structs/Result_ProbabilisticScorerDecodeErrorZ.mjs';
116 import { InitFeatures } from '../structs/InitFeatures.mjs';
117 import { Result_InitFeaturesDecodeErrorZ } from '../structs/Result_InitFeaturesDecodeErrorZ.mjs';
118 import { ChannelFeatures } from '../structs/ChannelFeatures.mjs';
119 import { Result_ChannelFeaturesDecodeErrorZ } from '../structs/Result_ChannelFeaturesDecodeErrorZ.mjs';
120 import { NodeFeatures } from '../structs/NodeFeatures.mjs';
121 import { Result_NodeFeaturesDecodeErrorZ } from '../structs/Result_NodeFeaturesDecodeErrorZ.mjs';
122 import { InvoiceFeatures } from '../structs/InvoiceFeatures.mjs';
123 import { Result_InvoiceFeaturesDecodeErrorZ } from '../structs/Result_InvoiceFeaturesDecodeErrorZ.mjs';
124 import { Result_ChannelTypeFeaturesDecodeErrorZ } from '../structs/Result_ChannelTypeFeaturesDecodeErrorZ.mjs';
125 import { NodeId } from '../structs/NodeId.mjs';
126 import { Result_NodeIdDecodeErrorZ } from '../structs/Result_NodeIdDecodeErrorZ.mjs';
127 import { Result_COption_NetworkUpdateZDecodeErrorZ } from '../structs/Result_COption_NetworkUpdateZDecodeErrorZ.mjs';
128 import { Access, AccessInterface } from '../structs/Access.mjs';
129 import { Option_AccessZ } from '../structs/Option_AccessZ.mjs';
130 import { Result_boolLightningErrorZ } from '../structs/Result_boolLightningErrorZ.mjs';
131 import { ThreeTuple_ChannelAnnouncementChannelUpdateChannelUpdateZ } from '../structs/ThreeTuple_ChannelAnnouncementChannelUpdateChannelUpdateZ.mjs';
132 import { Result_NoneLightningErrorZ } from '../structs/Result_NoneLightningErrorZ.mjs';
133 import { ChannelUpdateInfo } from '../structs/ChannelUpdateInfo.mjs';
134 import { Result_ChannelUpdateInfoDecodeErrorZ } from '../structs/Result_ChannelUpdateInfoDecodeErrorZ.mjs';
135 import { ChannelInfo } from '../structs/ChannelInfo.mjs';
136 import { Result_ChannelInfoDecodeErrorZ } from '../structs/Result_ChannelInfoDecodeErrorZ.mjs';
137 import { RoutingFees } from '../structs/RoutingFees.mjs';
138 import { Result_RoutingFeesDecodeErrorZ } from '../structs/Result_RoutingFeesDecodeErrorZ.mjs';
139 import { NetAddress } from '../structs/NetAddress.mjs';
140 import { NodeAnnouncementInfo } from '../structs/NodeAnnouncementInfo.mjs';
141 import { Result_NodeAnnouncementInfoDecodeErrorZ } from '../structs/Result_NodeAnnouncementInfoDecodeErrorZ.mjs';
142 import { NodeInfo } from '../structs/NodeInfo.mjs';
143 import { Result_NodeInfoDecodeErrorZ } from '../structs/Result_NodeInfoDecodeErrorZ.mjs';
144 import { Result_NetworkGraphDecodeErrorZ } from '../structs/Result_NetworkGraphDecodeErrorZ.mjs';
145 import { Option_CVec_NetAddressZZ } from '../structs/Option_CVec_NetAddressZZ.mjs';
146 import { Result_DelayedPaymentOutputDescriptorDecodeErrorZ } from '../structs/Result_DelayedPaymentOutputDescriptorDecodeErrorZ.mjs';
147 import { Result_StaticPaymentOutputDescriptorDecodeErrorZ } from '../structs/Result_StaticPaymentOutputDescriptorDecodeErrorZ.mjs';
148 import { Result_SpendableOutputDescriptorDecodeErrorZ } from '../structs/Result_SpendableOutputDescriptorDecodeErrorZ.mjs';
149 import { TwoTuple_SignatureCVec_SignatureZZ } from '../structs/TwoTuple_SignatureCVec_SignatureZZ.mjs';
150 import { Result_C2Tuple_SignatureCVec_SignatureZZNoneZ } from '../structs/Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.mjs';
151 import { Result_SignatureNoneZ } from '../structs/Result_SignatureNoneZ.mjs';
152 import { TwoTuple_SignatureSignatureZ } from '../structs/TwoTuple_SignatureSignatureZ.mjs';
153 import { Result_C2Tuple_SignatureSignatureZNoneZ } from '../structs/Result_C2Tuple_SignatureSignatureZNoneZ.mjs';
154 import { Result_SecretKeyNoneZ } from '../structs/Result_SecretKeyNoneZ.mjs';
155 import { ClosingTransaction } from '../structs/ClosingTransaction.mjs';
156 import { UnsignedChannelAnnouncement } from '../structs/UnsignedChannelAnnouncement.mjs';
157 import { BaseSign, BaseSignInterface } from '../structs/BaseSign.mjs';
158 import { Sign, SignInterface } from '../structs/Sign.mjs';
159 import { Result_SignDecodeErrorZ } from '../structs/Result_SignDecodeErrorZ.mjs';
160 import { Result_RecoverableSignatureNoneZ } from '../structs/Result_RecoverableSignatureNoneZ.mjs';
161 import { Result_CVec_CVec_u8ZZNoneZ } from '../structs/Result_CVec_CVec_u8ZZNoneZ.mjs';
162 import { InMemorySigner } from '../structs/InMemorySigner.mjs';
163 import { Result_InMemorySignerDecodeErrorZ } from '../structs/Result_InMemorySignerDecodeErrorZ.mjs';
164 import { Result_TransactionNoneZ } from '../structs/Result_TransactionNoneZ.mjs';
165 import { Option_u16Z } from '../structs/Option_u16Z.mjs';
166 import { APIError } from '../structs/APIError.mjs';
167 import { Result_NoneAPIErrorZ } from '../structs/Result_NoneAPIErrorZ.mjs';
168 import { Result__u832APIErrorZ } from '../structs/Result__u832APIErrorZ.mjs';
169 import { PaymentSendFailure } from '../structs/PaymentSendFailure.mjs';
170 import { Result_PaymentIdPaymentSendFailureZ } from '../structs/Result_PaymentIdPaymentSendFailureZ.mjs';
171 import { Result_NonePaymentSendFailureZ } from '../structs/Result_NonePaymentSendFailureZ.mjs';
172 import { TwoTuple_PaymentHashPaymentIdZ } from '../structs/TwoTuple_PaymentHashPaymentIdZ.mjs';
173 import { Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ } from '../structs/Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.mjs';
174 import { TwoTuple_PaymentHashPaymentSecretZ } from '../structs/TwoTuple_PaymentHashPaymentSecretZ.mjs';
175 import { Result_C2Tuple_PaymentHashPaymentSecretZNoneZ } from '../structs/Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.mjs';
176 import { Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ } from '../structs/Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ.mjs';
177 import { Result_PaymentSecretNoneZ } from '../structs/Result_PaymentSecretNoneZ.mjs';
178 import { Result_PaymentSecretAPIErrorZ } from '../structs/Result_PaymentSecretAPIErrorZ.mjs';
179 import { Result_PaymentPreimageAPIErrorZ } from '../structs/Result_PaymentPreimageAPIErrorZ.mjs';
180 import { CounterpartyForwardingInfo } from '../structs/CounterpartyForwardingInfo.mjs';
181 import { Result_CounterpartyForwardingInfoDecodeErrorZ } from '../structs/Result_CounterpartyForwardingInfoDecodeErrorZ.mjs';
182 import { ChannelCounterparty } from '../structs/ChannelCounterparty.mjs';
183 import { Result_ChannelCounterpartyDecodeErrorZ } from '../structs/Result_ChannelCounterpartyDecodeErrorZ.mjs';
184 import { Result_ChannelDetailsDecodeErrorZ } from '../structs/Result_ChannelDetailsDecodeErrorZ.mjs';
185 import { PhantomRouteHints } from '../structs/PhantomRouteHints.mjs';
186 import { Result_PhantomRouteHintsDecodeErrorZ } from '../structs/Result_PhantomRouteHintsDecodeErrorZ.mjs';
187 import { ChannelMonitor } from '../structs/ChannelMonitor.mjs';
188 import { ChannelMonitorUpdate } from '../structs/ChannelMonitorUpdate.mjs';
189 import { Watch, WatchInterface } from '../structs/Watch.mjs';
190 import { BroadcasterInterface, BroadcasterInterfaceInterface } from '../structs/BroadcasterInterface.mjs';
191 import { KeysInterface, KeysInterfaceInterface } from '../structs/KeysInterface.mjs';
192 import { FeeEstimator, FeeEstimatorInterface } from '../structs/FeeEstimator.mjs';
193 import { ChannelManager } from '../structs/ChannelManager.mjs';
194 import { TwoTuple_BlockHashChannelManagerZ } from '../structs/TwoTuple_BlockHashChannelManagerZ.mjs';
195 import { Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ } from '../structs/Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.mjs';
196 import { ChannelConfig } from '../structs/ChannelConfig.mjs';
197 import { Result_ChannelConfigDecodeErrorZ } from '../structs/Result_ChannelConfigDecodeErrorZ.mjs';
198 import { Result_OutPointDecodeErrorZ } from '../structs/Result_OutPointDecodeErrorZ.mjs';
199 import { Type, TypeInterface } from '../structs/Type.mjs';
200 import { Option_TypeZ } from '../structs/Option_TypeZ.mjs';
201 import { Result_COption_TypeZDecodeErrorZ } from '../structs/Result_COption_TypeZDecodeErrorZ.mjs';
202 import { PaymentError } from '../structs/PaymentError.mjs';
203 import { Result_PaymentIdPaymentErrorZ } from '../structs/Result_PaymentIdPaymentErrorZ.mjs';
204 import { ParseError } from '../structs/ParseError.mjs';
205 import { Result_SiPrefixParseErrorZ } from '../structs/Result_SiPrefixParseErrorZ.mjs';
206 import { Invoice } from '../structs/Invoice.mjs';
207 import { ParseOrSemanticError } from '../structs/ParseOrSemanticError.mjs';
208 import { Result_InvoiceParseOrSemanticErrorZ } from '../structs/Result_InvoiceParseOrSemanticErrorZ.mjs';
209 import { SignedRawInvoice } from '../structs/SignedRawInvoice.mjs';
210 import { Result_SignedRawInvoiceParseErrorZ } from '../structs/Result_SignedRawInvoiceParseErrorZ.mjs';
211 import { RawInvoice } from '../structs/RawInvoice.mjs';
212 import { InvoiceSignature } from '../structs/InvoiceSignature.mjs';
213 import { ThreeTuple_RawInvoice_u832InvoiceSignatureZ } from '../structs/ThreeTuple_RawInvoice_u832InvoiceSignatureZ.mjs';
214 import { PayeePubKey } from '../structs/PayeePubKey.mjs';
215 import { Result_PayeePubKeyErrorZ } from '../structs/Result_PayeePubKeyErrorZ.mjs';
216 import { PrivateRoute } from '../structs/PrivateRoute.mjs';
217 import { PositiveTimestamp } from '../structs/PositiveTimestamp.mjs';
218 import { Result_PositiveTimestampCreationErrorZ } from '../structs/Result_PositiveTimestampCreationErrorZ.mjs';
219 import { Result_NoneSemanticErrorZ } from '../structs/Result_NoneSemanticErrorZ.mjs';
220 import { Result_InvoiceSemanticErrorZ } from '../structs/Result_InvoiceSemanticErrorZ.mjs';
221 import { Description } from '../structs/Description.mjs';
222 import { Result_DescriptionCreationErrorZ } from '../structs/Result_DescriptionCreationErrorZ.mjs';
223 import { Result_PrivateRouteCreationErrorZ } from '../structs/Result_PrivateRouteCreationErrorZ.mjs';
224 import { Result_StringErrorZ } from '../structs/Result_StringErrorZ.mjs';
225 import { Result_ChannelMonitorUpdateDecodeErrorZ } from '../structs/Result_ChannelMonitorUpdateDecodeErrorZ.mjs';
226 import { Option_MonitorEventZ } from '../structs/Option_MonitorEventZ.mjs';
227 import { Result_COption_MonitorEventZDecodeErrorZ } from '../structs/Result_COption_MonitorEventZDecodeErrorZ.mjs';
228 import { Result_HTLCUpdateDecodeErrorZ } from '../structs/Result_HTLCUpdateDecodeErrorZ.mjs';
229 import { TwoTuple_OutPointScriptZ } from '../structs/TwoTuple_OutPointScriptZ.mjs';
230 import { TwoTuple_u32ScriptZ } from '../structs/TwoTuple_u32ScriptZ.mjs';
231 import { TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ } from '../structs/TwoTuple_TxidCVec_C2Tuple_u32ScriptZZZ.mjs';
232 import { TwoTuple_u32TxOutZ } from '../structs/TwoTuple_u32TxOutZ.mjs';
233 import { TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ } from '../structs/TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ.mjs';
234 import { Balance } from '../structs/Balance.mjs';
235 import { TwoTuple_BlockHashChannelMonitorZ } from '../structs/TwoTuple_BlockHashChannelMonitorZ.mjs';
236 import { Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ } from '../structs/Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.mjs';
237 import { TwoTuple_PublicKeyTypeZ } from '../structs/TwoTuple_PublicKeyTypeZ.mjs';
238 import { Option_NetAddressZ } from '../structs/Option_NetAddressZ.mjs';
239 import { PeerHandleError } from '../structs/PeerHandleError.mjs';
240 import { Result_CVec_u8ZPeerHandleErrorZ } from '../structs/Result_CVec_u8ZPeerHandleErrorZ.mjs';
241 import { Result_NonePeerHandleErrorZ } from '../structs/Result_NonePeerHandleErrorZ.mjs';
242 import { Result_boolPeerHandleErrorZ } from '../structs/Result_boolPeerHandleErrorZ.mjs';
243 import { Result_NoneErrorZ } from '../structs/Result_NoneErrorZ.mjs';
244 import { Result_NetAddressDecodeErrorZ } from '../structs/Result_NetAddressDecodeErrorZ.mjs';
245 import { UpdateAddHTLC } from '../structs/UpdateAddHTLC.mjs';
246 import { UpdateFulfillHTLC } from '../structs/UpdateFulfillHTLC.mjs';
247 import { UpdateFailHTLC } from '../structs/UpdateFailHTLC.mjs';
248 import { UpdateFailMalformedHTLC } from '../structs/UpdateFailMalformedHTLC.mjs';
249 import { Result_AcceptChannelDecodeErrorZ } from '../structs/Result_AcceptChannelDecodeErrorZ.mjs';
250 import { Result_AnnouncementSignaturesDecodeErrorZ } from '../structs/Result_AnnouncementSignaturesDecodeErrorZ.mjs';
251 import { Result_ChannelReestablishDecodeErrorZ } from '../structs/Result_ChannelReestablishDecodeErrorZ.mjs';
252 import { Result_ClosingSignedDecodeErrorZ } from '../structs/Result_ClosingSignedDecodeErrorZ.mjs';
253 import { ClosingSignedFeeRange } from '../structs/ClosingSignedFeeRange.mjs';
254 import { Result_ClosingSignedFeeRangeDecodeErrorZ } from '../structs/Result_ClosingSignedFeeRangeDecodeErrorZ.mjs';
255 import { CommitmentSigned } from '../structs/CommitmentSigned.mjs';
256 import { Result_CommitmentSignedDecodeErrorZ } from '../structs/Result_CommitmentSignedDecodeErrorZ.mjs';
257 import { Result_FundingCreatedDecodeErrorZ } from '../structs/Result_FundingCreatedDecodeErrorZ.mjs';
258 import { Result_FundingSignedDecodeErrorZ } from '../structs/Result_FundingSignedDecodeErrorZ.mjs';
259 import { Result_ChannelReadyDecodeErrorZ } from '../structs/Result_ChannelReadyDecodeErrorZ.mjs';
260 import { Init } from '../structs/Init.mjs';
261 import { Result_InitDecodeErrorZ } from '../structs/Result_InitDecodeErrorZ.mjs';
262 import { Result_OpenChannelDecodeErrorZ } from '../structs/Result_OpenChannelDecodeErrorZ.mjs';
263 import { Result_RevokeAndACKDecodeErrorZ } from '../structs/Result_RevokeAndACKDecodeErrorZ.mjs';
264 import { Result_ShutdownDecodeErrorZ } from '../structs/Result_ShutdownDecodeErrorZ.mjs';
265 import { Result_UpdateFailHTLCDecodeErrorZ } from '../structs/Result_UpdateFailHTLCDecodeErrorZ.mjs';
266 import { Result_UpdateFailMalformedHTLCDecodeErrorZ } from '../structs/Result_UpdateFailMalformedHTLCDecodeErrorZ.mjs';
267 import { UpdateFee } from '../structs/UpdateFee.mjs';
268 import { Result_UpdateFeeDecodeErrorZ } from '../structs/Result_UpdateFeeDecodeErrorZ.mjs';
269 import { Result_UpdateFulfillHTLCDecodeErrorZ } from '../structs/Result_UpdateFulfillHTLCDecodeErrorZ.mjs';
270 import { Result_UpdateAddHTLCDecodeErrorZ } from '../structs/Result_UpdateAddHTLCDecodeErrorZ.mjs';
271 import { Ping } from '../structs/Ping.mjs';
272 import { Result_PingDecodeErrorZ } from '../structs/Result_PingDecodeErrorZ.mjs';
273 import { Pong } from '../structs/Pong.mjs';
274 import { Result_PongDecodeErrorZ } from '../structs/Result_PongDecodeErrorZ.mjs';
275 import { Result_UnsignedChannelAnnouncementDecodeErrorZ } from '../structs/Result_UnsignedChannelAnnouncementDecodeErrorZ.mjs';
276 import { Result_ChannelAnnouncementDecodeErrorZ } from '../structs/Result_ChannelAnnouncementDecodeErrorZ.mjs';
277 import { UnsignedChannelUpdate } from '../structs/UnsignedChannelUpdate.mjs';
278 import { Result_UnsignedChannelUpdateDecodeErrorZ } from '../structs/Result_UnsignedChannelUpdateDecodeErrorZ.mjs';
279 import { Result_ChannelUpdateDecodeErrorZ } from '../structs/Result_ChannelUpdateDecodeErrorZ.mjs';
280 import { Result_ErrorMessageDecodeErrorZ } from '../structs/Result_ErrorMessageDecodeErrorZ.mjs';
281 import { Result_WarningMessageDecodeErrorZ } from '../structs/Result_WarningMessageDecodeErrorZ.mjs';
282 import { UnsignedNodeAnnouncement } from '../structs/UnsignedNodeAnnouncement.mjs';
283 import { Result_UnsignedNodeAnnouncementDecodeErrorZ } from '../structs/Result_UnsignedNodeAnnouncementDecodeErrorZ.mjs';
284 import { Result_NodeAnnouncementDecodeErrorZ } from '../structs/Result_NodeAnnouncementDecodeErrorZ.mjs';
285 import { Result_QueryShortChannelIdsDecodeErrorZ } from '../structs/Result_QueryShortChannelIdsDecodeErrorZ.mjs';
286 import { ReplyShortChannelIdsEnd } from '../structs/ReplyShortChannelIdsEnd.mjs';
287 import { Result_ReplyShortChannelIdsEndDecodeErrorZ } from '../structs/Result_ReplyShortChannelIdsEndDecodeErrorZ.mjs';
288 import { Result_QueryChannelRangeDecodeErrorZ } from '../structs/Result_QueryChannelRangeDecodeErrorZ.mjs';
289 import { Result_ReplyChannelRangeDecodeErrorZ } from '../structs/Result_ReplyChannelRangeDecodeErrorZ.mjs';
290 import { Result_GossipTimestampFilterDecodeErrorZ } from '../structs/Result_GossipTimestampFilterDecodeErrorZ.mjs';
291 import { SignOrCreationError } from '../structs/SignOrCreationError.mjs';
292 import { Result_InvoiceSignOrCreationErrorZ } from '../structs/Result_InvoiceSignOrCreationErrorZ.mjs';
293 import { WatchedOutput } from '../structs/WatchedOutput.mjs';
294 import { Filter, FilterInterface } from '../structs/Filter.mjs';
295 import { Option_FilterZ } from '../structs/Option_FilterZ.mjs';
296 import { LockedChannelMonitor } from '../structs/LockedChannelMonitor.mjs';
297 import { Result_LockedChannelMonitorNoneZ } from '../structs/Result_LockedChannelMonitorNoneZ.mjs';
298 import { MessageSendEventsProvider, MessageSendEventsProviderInterface } from '../structs/MessageSendEventsProvider.mjs';
299 import { EventHandler, EventHandlerInterface } from '../structs/EventHandler.mjs';
300 import { EventsProvider, EventsProviderInterface } from '../structs/EventsProvider.mjs';
301 import { BigSize } from '../structs/BigSize.mjs';
302 import { ChannelUsage } from '../structs/ChannelUsage.mjs';
303 import { Score, ScoreInterface } from '../structs/Score.mjs';
304 import { MultiThreadedLockableScore } from '../structs/MultiThreadedLockableScore.mjs';
305 import { Persister, PersisterInterface } from '../structs/Persister.mjs';
306 import { ChannelHandshakeConfig } from '../structs/ChannelHandshakeConfig.mjs';
307 import { ChannelHandshakeLimits } from '../structs/ChannelHandshakeLimits.mjs';
308 import { UserConfig } from '../structs/UserConfig.mjs';
309 import { BestBlock } from '../structs/BestBlock.mjs';
310 import { Listen, ListenInterface } from '../structs/Listen.mjs';
311 import { Confirm, ConfirmInterface } from '../structs/Confirm.mjs';
312 import { MonitorUpdateId } from '../structs/MonitorUpdateId.mjs';
313 import { Persist, PersistInterface } from '../structs/Persist.mjs';
314 import { ChainMonitor } from '../structs/ChainMonitor.mjs';
315 import { KeysManager } from '../structs/KeysManager.mjs';
316 import { PhantomKeysManager } from '../structs/PhantomKeysManager.mjs';
317 import { ChainParameters } from '../structs/ChainParameters.mjs';
318 import { ChannelMessageHandler, ChannelMessageHandlerInterface } from '../structs/ChannelMessageHandler.mjs';
319 import { ChannelManagerReadArgs } from '../structs/ChannelManagerReadArgs.mjs';
320 import { ExpandedKey } from '../structs/ExpandedKey.mjs';
321 import { DataLossProtect } from '../structs/DataLossProtect.mjs';
322 import { RoutingMessageHandler, RoutingMessageHandlerInterface } from '../structs/RoutingMessageHandler.mjs';
323 import { CustomMessageReader, CustomMessageReaderInterface } from '../structs/CustomMessageReader.mjs';
324 import { CustomMessageHandler, CustomMessageHandlerInterface } from '../structs/CustomMessageHandler.mjs';
325 import { IgnoringMessageHandler } from '../structs/IgnoringMessageHandler.mjs';
326 import { ErroringMessageHandler } from '../structs/ErroringMessageHandler.mjs';
327 import { MessageHandler } from '../structs/MessageHandler.mjs';
328 import { SocketDescriptor, SocketDescriptorInterface } from '../structs/SocketDescriptor.mjs';
329 import { PeerManager } from '../structs/PeerManager.mjs';
330 import { DirectedChannelTransactionParameters } from '../structs/DirectedChannelTransactionParameters.mjs';
331 import { ReadOnlyNetworkGraph } from '../structs/ReadOnlyNetworkGraph.mjs';
332 import { P2PGossipSync } from '../structs/P2PGossipSync.mjs';
333 import { DirectedChannelInfo } from '../structs/DirectedChannelInfo.mjs';
334 import { EffectiveCapacity } from '../structs/EffectiveCapacity.mjs';
335 import { LockableScore, LockableScoreInterface } from '../structs/LockableScore.mjs';
336 import { ProbabilisticScoringParameters } from '../structs/ProbabilisticScoringParameters.mjs';
337 import { RawDataPart } from '../structs/RawDataPart.mjs';
338 import { Sha256 } from '../structs/Sha256.mjs';
339 import { ExpiryTime } from '../structs/ExpiryTime.mjs';
340 import { MinFinalCltvExpiry } from '../structs/MinFinalCltvExpiry.mjs';
341 import { Fallback } from '../structs/Fallback.mjs';
342 import { Payer, PayerInterface } from '../structs/Payer.mjs';
343 import { Router, RouterInterface } from '../structs/Router.mjs';
344 import { InvoicePayer } from '../structs/InvoicePayer.mjs';
345 import { Retry } from '../structs/Retry.mjs';
346 import { DefaultRouter } from '../structs/DefaultRouter.mjs';
347
348 import { CommonBase, UInt5, WitnessVersion, UnqualifiedError } from './CommonBase.mjs';
349 import * as bindings from '../bindings.mjs'
350
351
352 export class UtilMethods extends CommonBase {
353         /**
354          * Constructs a new COption_NoneZ containing a
355          */
356         public static constructor_COption_NoneZ_some(): COption_NoneZ {
357                 const ret: COption_NoneZ = bindings.COption_NoneZ_some();
358                 return ret;
359         }
360
361         /**
362          * Constructs a new COption_NoneZ containing nothing
363          */
364         public static constructor_COption_NoneZ_none(): COption_NoneZ {
365                 const ret: COption_NoneZ = bindings.COption_NoneZ_none();
366                 return ret;
367         }
368
369         /**
370          * Read a ClosureReason from a byte array, created by ClosureReason_write
371          */
372         public static constructor_ClosureReason_read(ser: Uint8Array): Result_COption_ClosureReasonZDecodeErrorZ {
373                 const ret: number = bindings.ClosureReason_read(bindings.encodeUint8Array(ser));
374                 const ret_hu_conv: Result_COption_ClosureReasonZDecodeErrorZ = Result_COption_ClosureReasonZDecodeErrorZ.constr_from_ptr(ret);
375                 return ret_hu_conv;
376         }
377
378         /**
379          * Read a Event from a byte array, created by Event_write
380          */
381         public static constructor_Event_read(ser: Uint8Array): Result_COption_EventZDecodeErrorZ {
382                 const ret: number = bindings.Event_read(bindings.encodeUint8Array(ser));
383                 const ret_hu_conv: Result_COption_EventZDecodeErrorZ = Result_COption_EventZDecodeErrorZ.constr_from_ptr(ret);
384                 return ret_hu_conv;
385         }
386
387         /**
388          * Creates a digital signature of a message given a SecretKey, like the node's secret.
389          * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller.
390          * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted.
391          */
392         public static constructor_sign(msg: Uint8Array, sk: Uint8Array): Result_StringErrorZ {
393                 const ret: number = bindings.sign(bindings.encodeUint8Array(msg), bindings.encodeUint8Array(bindings.check_arr_len(sk, 32)));
394                 const ret_hu_conv: Result_StringErrorZ = Result_StringErrorZ.constr_from_ptr(ret);
395                 return ret_hu_conv;
396         }
397
398         /**
399          * Recovers the PublicKey of the signer of the message given the message and the signature.
400          */
401         public static constructor_recover_pk(msg: Uint8Array, sig: string): Result_PublicKeyErrorZ {
402                 const ret: number = bindings.recover_pk(bindings.encodeUint8Array(msg), bindings.encodeString(sig));
403                 const ret_hu_conv: Result_PublicKeyErrorZ = Result_PublicKeyErrorZ.constr_from_ptr(ret);
404                 return ret_hu_conv;
405         }
406
407         /**
408          * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature,
409          * and the PublicKey.
410          */
411         public static constructor_verify(msg: Uint8Array, sig: string, pk: Uint8Array): boolean {
412                 const ret: boolean = bindings.verify(bindings.encodeUint8Array(msg), bindings.encodeString(sig), bindings.encodeUint8Array(bindings.check_arr_len(pk, 33)));
413                 return ret;
414         }
415
416         /**
417          * Construct the invoice's HRP and signatureless data into a preimage to be hashed.
418          */
419         public static constructor_construct_invoice_preimage(hrp_bytes: Uint8Array, data_without_signature: UInt5[]): Uint8Array {
420                 const ret: number = bindings.construct_invoice_preimage(bindings.encodeUint8Array(hrp_bytes), bindings.encodeUint8Array(data_without_signature != null ? bindings.uint5ArrToBytes(data_without_signature) : null));
421                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
422                 return ret_conv;
423         }
424
425         /**
426          * Read a MonitorEvent from a byte array, created by MonitorEvent_write
427          */
428         public static constructor_MonitorEvent_read(ser: Uint8Array): Result_COption_MonitorEventZDecodeErrorZ {
429                 const ret: number = bindings.MonitorEvent_read(bindings.encodeUint8Array(ser));
430                 const ret_hu_conv: Result_COption_MonitorEventZDecodeErrorZ = Result_COption_MonitorEventZDecodeErrorZ.constr_from_ptr(ret);
431                 return ret_hu_conv;
432         }
433
434         /**
435          * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write
436          */
437         public static constructor_C2Tuple_BlockHashChannelMonitorZ_read(ser: Uint8Array, arg: KeysInterface): Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
438                 const ret: number = bindings.C2Tuple_BlockHashChannelMonitorZ_read(bindings.encodeUint8Array(ser), arg == null ? 0 : CommonBase.get_ptr_of(arg));
439                 const ret_hu_conv: Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ = Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.constr_from_ptr(ret);
440                 CommonBase.add_ref_from(ret_hu_conv, arg);
441                 return ret_hu_conv;
442         }
443
444         /**
445          * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
446          */
447         public static constructor_C2Tuple_BlockHashChannelManagerZ_read(ser: Uint8Array, arg_keys_manager: KeysInterface, arg_fee_estimator: FeeEstimator, arg_chain_monitor: Watch, arg_tx_broadcaster: BroadcasterInterface, arg_logger: Logger, arg_default_config: UserConfig, arg_channel_monitors: ChannelMonitor[]): Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
448                 const ret: number = bindings.C2Tuple_BlockHashChannelManagerZ_read(bindings.encodeUint8Array(ser), bindings.ChannelManagerReadArgs_new(arg_keys_manager == null ? 0 : CommonBase.get_ptr_of(arg_keys_manager), arg_fee_estimator == null ? 0 : CommonBase.get_ptr_of(arg_fee_estimator), arg_chain_monitor == null ? 0 : CommonBase.get_ptr_of(arg_chain_monitor), arg_tx_broadcaster == null ? 0 : CommonBase.get_ptr_of(arg_tx_broadcaster), arg_logger == null ? 0 : CommonBase.get_ptr_of(arg_logger), arg_default_config == null ? 0 : CommonBase.get_ptr_of(arg_default_config) & ~1, bindings.encodeUint32Array(arg_channel_monitors != null ? arg_channel_monitors.map(arg_channel_monitors_conv_16 => arg_channel_monitors_conv_16 == null ? 0 : CommonBase.get_ptr_of(arg_channel_monitors_conv_16) & ~1) : null)));
449                 const ret_hu_conv: Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ = Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.constr_from_ptr(ret);
450                 CommonBase.add_ref_from(ret_hu_conv, arg_keys_manager);
451                 CommonBase.add_ref_from(ret_hu_conv, arg_fee_estimator);
452                 CommonBase.add_ref_from(ret_hu_conv, arg_chain_monitor);
453                 CommonBase.add_ref_from(ret_hu_conv, arg_tx_broadcaster);
454                 CommonBase.add_ref_from(ret_hu_conv, arg_logger);
455                 ;
456                 arg_channel_monitors.forEach((arg_channel_monitors_conv_16: ChannelMonitor) => { CommonBase.add_ref_from(ret_hu_conv, arg_channel_monitors_conv_16); });
457                 return ret_hu_conv;
458         }
459
460         /**
461          * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no
462          * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without
463          * a `ChannelManager`.
464          * 
465          * `keys` is generated by calling [`KeysInterface::get_inbound_payment_key_material`] and then
466          * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not
467          * regenerate it for each new inbound payment.
468          * 
469          * `current_time` is a Unix timestamp representing the current time.
470          * 
471          * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
472          */
473         public static constructor_create(keys: ExpandedKey, min_value_msat: Option_u64Z, invoice_expiry_delta_secs: number, keys_manager: KeysInterface, current_time: bigint): Result_C2Tuple_PaymentHashPaymentSecretZNoneZ {
474                 const ret: number = bindings.create(keys == null ? 0 : CommonBase.get_ptr_of(keys) & ~1, CommonBase.get_ptr_of(min_value_msat), invoice_expiry_delta_secs, keys_manager == null ? 0 : CommonBase.get_ptr_of(keys_manager), current_time);
475                 const ret_hu_conv: Result_C2Tuple_PaymentHashPaymentSecretZNoneZ = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret);
476                 CommonBase.add_ref_from(ret_hu_conv, keys);
477                 CommonBase.add_ref_from(ret_hu_conv, keys_manager);
478                 return ret_hu_conv;
479         }
480
481         /**
482          * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`],
483          * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments]
484          * without a `ChannelManager`.
485          * 
486          * See [`create`] for information on the `keys` and `current_time` parameters.
487          * 
488          * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
489          */
490         public static constructor_create_from_hash(keys: ExpandedKey, min_value_msat: Option_u64Z, payment_hash: Uint8Array, invoice_expiry_delta_secs: number, current_time: bigint): Result_PaymentSecretNoneZ {
491                 const ret: number = bindings.create_from_hash(keys == null ? 0 : CommonBase.get_ptr_of(keys) & ~1, CommonBase.get_ptr_of(min_value_msat), bindings.encodeUint8Array(bindings.check_arr_len(payment_hash, 32)), invoice_expiry_delta_secs, current_time);
492                 const ret_hu_conv: Result_PaymentSecretNoneZ = Result_PaymentSecretNoneZ.constr_from_ptr(ret);
493                 CommonBase.add_ref_from(ret_hu_conv, keys);
494                 return ret_hu_conv;
495         }
496
497         /**
498          * Gets the weight for an HTLC-Success transaction.
499          */
500         public static constructor_htlc_success_tx_weight(opt_anchors: boolean): bigint {
501                 const ret: bigint = bindings.htlc_success_tx_weight(opt_anchors);
502                 return ret;
503         }
504
505         /**
506          * Gets the weight for an HTLC-Timeout transaction.
507          */
508         public static constructor_htlc_timeout_tx_weight(opt_anchors: boolean): bigint {
509                 const ret: bigint = bindings.htlc_timeout_tx_weight(opt_anchors);
510                 return ret;
511         }
512
513         /**
514          * Build the commitment secret from the seed and the commitment number
515          */
516         public static constructor_build_commitment_secret(commitment_seed: Uint8Array, idx: bigint): Uint8Array {
517                 const ret: number = bindings.build_commitment_secret(bindings.encodeUint8Array(bindings.check_arr_len(commitment_seed, 32)), idx);
518                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
519                 return ret_conv;
520         }
521
522         /**
523          * Build a closing transaction
524          */
525         public static constructor_build_closing_transaction(to_holder_value_sat: bigint, to_counterparty_value_sat: bigint, to_holder_script: Uint8Array, to_counterparty_script: Uint8Array, funding_outpoint: OutPoint): Uint8Array {
526                 const ret: number = bindings.build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, bindings.encodeUint8Array(to_holder_script), bindings.encodeUint8Array(to_counterparty_script), funding_outpoint == null ? 0 : CommonBase.get_ptr_of(funding_outpoint) & ~1);
527                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
528                 return ret_conv;
529         }
530
531         /**
532          * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
533          * from the base secret and the per_commitment_point.
534          * 
535          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
536          * generated (ie our own).
537          */
538         public static constructor_derive_private_key(per_commitment_point: Uint8Array, base_secret: Uint8Array): Result_SecretKeyErrorZ {
539                 const ret: number = bindings.derive_private_key(bindings.encodeUint8Array(bindings.check_arr_len(per_commitment_point, 33)), bindings.encodeUint8Array(bindings.check_arr_len(base_secret, 32)));
540                 const ret_hu_conv: Result_SecretKeyErrorZ = Result_SecretKeyErrorZ.constr_from_ptr(ret);
541                 return ret_hu_conv;
542         }
543
544         /**
545          * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key)
546          * from the base point and the per_commitment_key. This is the public equivalent of
547          * derive_private_key - using only public keys to derive a public key instead of private keys.
548          * 
549          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
550          * generated (ie our own).
551          */
552         public static constructor_derive_public_key(per_commitment_point: Uint8Array, base_point: Uint8Array): Result_PublicKeyErrorZ {
553                 const ret: number = bindings.derive_public_key(bindings.encodeUint8Array(bindings.check_arr_len(per_commitment_point, 33)), bindings.encodeUint8Array(bindings.check_arr_len(base_point, 33)));
554                 const ret_hu_conv: Result_PublicKeyErrorZ = Result_PublicKeyErrorZ.constr_from_ptr(ret);
555                 return ret_hu_conv;
556         }
557
558         /**
559          * Derives a per-commitment-transaction revocation key from its constituent parts.
560          * 
561          * Only the cheating participant owns a valid witness to propagate a revoked
562          * commitment transaction, thus per_commitment_secret always come from cheater
563          * and revocation_base_secret always come from punisher, which is the broadcaster
564          * of the transaction spending with this key knowledge.
565          * 
566          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
567          * generated (ie our own).
568          */
569         public static constructor_derive_private_revocation_key(per_commitment_secret: Uint8Array, countersignatory_revocation_base_secret: Uint8Array): Result_SecretKeyErrorZ {
570                 const ret: number = bindings.derive_private_revocation_key(bindings.encodeUint8Array(bindings.check_arr_len(per_commitment_secret, 32)), bindings.encodeUint8Array(bindings.check_arr_len(countersignatory_revocation_base_secret, 32)));
571                 const ret_hu_conv: Result_SecretKeyErrorZ = Result_SecretKeyErrorZ.constr_from_ptr(ret);
572                 return ret_hu_conv;
573         }
574
575         /**
576          * Derives a per-commitment-transaction revocation public key from its constituent parts. This is
577          * the public equivalend of derive_private_revocation_key - using only public keys to derive a
578          * public key instead of private keys.
579          * 
580          * Only the cheating participant owns a valid witness to propagate a revoked
581          * commitment transaction, thus per_commitment_point always come from cheater
582          * and revocation_base_point always come from punisher, which is the broadcaster
583          * of the transaction spending with this key knowledge.
584          * 
585          * Note that this is infallible iff we trust that at least one of the two input keys are randomly
586          * generated (ie our own).
587          */
588         public static constructor_derive_public_revocation_key(per_commitment_point: Uint8Array, countersignatory_revocation_base_point: Uint8Array): Result_PublicKeyErrorZ {
589                 const ret: number = bindings.derive_public_revocation_key(bindings.encodeUint8Array(bindings.check_arr_len(per_commitment_point, 33)), bindings.encodeUint8Array(bindings.check_arr_len(countersignatory_revocation_base_point, 33)));
590                 const ret_hu_conv: Result_PublicKeyErrorZ = Result_PublicKeyErrorZ.constr_from_ptr(ret);
591                 return ret_hu_conv;
592         }
593
594         /**
595          * A script either spendable by the revocation
596          * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
597          * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
598          */
599         public static constructor_get_revokeable_redeemscript(revocation_key: Uint8Array, contest_delay: number, broadcaster_delayed_payment_key: Uint8Array): Uint8Array {
600                 const ret: number = bindings.get_revokeable_redeemscript(bindings.encodeUint8Array(bindings.check_arr_len(revocation_key, 33)), contest_delay, bindings.encodeUint8Array(bindings.check_arr_len(broadcaster_delayed_payment_key, 33)));
601                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
602                 return ret_conv;
603         }
604
605         /**
606          * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
607          * does not need to have its previous_output_index filled.
608          */
609         public static constructor_get_htlc_redeemscript(htlc: HTLCOutputInCommitment, opt_anchors: boolean, keys: TxCreationKeys): Uint8Array {
610                 const ret: number = bindings.get_htlc_redeemscript(htlc == null ? 0 : CommonBase.get_ptr_of(htlc) & ~1, opt_anchors, keys == null ? 0 : CommonBase.get_ptr_of(keys) & ~1);
611                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
612                 return ret_conv;
613         }
614
615         /**
616          * Gets the redeemscript for a funding output from the two funding public keys.
617          * Note that the order of funding public keys does not matter.
618          */
619         public static constructor_make_funding_redeemscript(broadcaster: Uint8Array, countersignatory: Uint8Array): Uint8Array {
620                 const ret: number = bindings.make_funding_redeemscript(bindings.encodeUint8Array(bindings.check_arr_len(broadcaster, 33)), bindings.encodeUint8Array(bindings.check_arr_len(countersignatory, 33)));
621                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
622                 return ret_conv;
623         }
624
625         /**
626          * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
627          * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
628          * transaction which needs signing, and can be used to construct an HTLC transaction which is
629          * broadcastable given a counterparty HTLC signature.
630          * 
631          * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
632          * commitment transaction).
633          */
634         public static constructor_build_htlc_transaction(commitment_txid: Uint8Array, feerate_per_kw: number, contest_delay: number, htlc: HTLCOutputInCommitment, opt_anchors: boolean, broadcaster_delayed_payment_key: Uint8Array, revocation_key: Uint8Array): Uint8Array {
635                 const ret: number = bindings.build_htlc_transaction(bindings.encodeUint8Array(bindings.check_arr_len(commitment_txid, 32)), feerate_per_kw, contest_delay, htlc == null ? 0 : CommonBase.get_ptr_of(htlc) & ~1, opt_anchors, bindings.encodeUint8Array(bindings.check_arr_len(broadcaster_delayed_payment_key, 33)), bindings.encodeUint8Array(bindings.check_arr_len(revocation_key, 33)));
636                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
637                 return ret_conv;
638         }
639
640         /**
641          * Gets the witnessScript for an anchor output from the funding public key.
642          * The witness in the spending input must be:
643          * <BIP 143 funding_signature>
644          * After 16 blocks of confirmation, an alternative satisfying witness could be:
645          * <>
646          * (empty vector required to satisfy compliance with MINIMALIF-standard rule)
647          */
648         public static constructor_get_anchor_redeemscript(funding_pubkey: Uint8Array): Uint8Array {
649                 const ret: number = bindings.get_anchor_redeemscript(bindings.encodeUint8Array(bindings.check_arr_len(funding_pubkey, 33)));
650                 const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
651                 return ret_conv;
652         }
653
654         /**
655          * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
656          * shared secret first. This prevents on-chain observers from discovering how many commitment
657          * transactions occurred in a channel before it was closed.
658          * 
659          * This function gets the shared secret from relevant channel public keys and can be used to
660          * \"decrypt\" the commitment transaction number given a commitment transaction on-chain.
661          */
662         public static constructor_get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint: Uint8Array, countersignatory_payment_basepoint: Uint8Array, outbound_from_broadcaster: boolean): bigint {
663                 const ret: bigint = bindings.get_commitment_transaction_number_obscure_factor(bindings.encodeUint8Array(bindings.check_arr_len(broadcaster_payment_basepoint, 33)), bindings.encodeUint8Array(bindings.check_arr_len(countersignatory_payment_basepoint, 33)), outbound_from_broadcaster);
664                 return ret;
665         }
666
667         /**
668          * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write
669          */
670         public static constructor_NetworkUpdate_read(ser: Uint8Array): Result_COption_NetworkUpdateZDecodeErrorZ {
671                 const ret: number = bindings.NetworkUpdate_read(bindings.encodeUint8Array(ser));
672                 const ret_hu_conv: Result_COption_NetworkUpdateZDecodeErrorZ = Result_COption_NetworkUpdateZDecodeErrorZ.constr_from_ptr(ret);
673                 return ret_hu_conv;
674         }
675
676         /**
677          * Finds a route from us (payer) to the given target node (payee).
678          * 
679          * If the payee provided features in their invoice, they should be provided via `params.payee`.
680          * Without this, MPP will only be used if the payee's features are available in the network graph.
681          * 
682          * Private routing paths between a public node and the target may be included in `params.payee`.
683          * 
684          * If some channels aren't announced, it may be useful to fill in `first_hops` with the results
685          * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels
686          * from `network_graph` will be ignored, and only those in `first_hops` will be used.
687          * 
688          * The fees on channels from us to the next hop are ignored as they are assumed to all be equal.
689          * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
690          * `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
691          * 
692          * # Note
693          * 
694          * May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any
695          * adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this
696          * function.
697          * 
698          * # Panics
699          * 
700          * Panics if first_hops contains channels without short_channel_ids;
701          * [`ChannelManager::list_usable_channels`] will never include such channels.
702          * 
703          * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
704          * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
705          * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
706          * 
707          * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
708          */
709         public static constructor_find_route(our_node_pubkey: Uint8Array, route_params: RouteParameters, network_graph: NetworkGraph, first_hops: ChannelDetails[], logger: Logger, scorer: Score, random_seed_bytes: Uint8Array): Result_RouteLightningErrorZ {
710                 const ret: number = bindings.find_route(bindings.encodeUint8Array(bindings.check_arr_len(our_node_pubkey, 33)), route_params == null ? 0 : CommonBase.get_ptr_of(route_params) & ~1, network_graph == null ? 0 : CommonBase.get_ptr_of(network_graph) & ~1, bindings.encodeUint32Array(first_hops != null ? first_hops.map(first_hops_conv_16 => first_hops_conv_16 == null ? 0 : CommonBase.get_ptr_of(first_hops_conv_16) & ~1) : null), logger == null ? 0 : CommonBase.get_ptr_of(logger), scorer == null ? 0 : CommonBase.get_ptr_of(scorer), bindings.encodeUint8Array(bindings.check_arr_len(random_seed_bytes, 32)));
711                 const ret_hu_conv: Result_RouteLightningErrorZ = Result_RouteLightningErrorZ.constr_from_ptr(ret);
712                 CommonBase.add_ref_from(ret_hu_conv, route_params);
713                 CommonBase.add_ref_from(ret_hu_conv, network_graph);
714                 first_hops.forEach((first_hops_conv_16: ChannelDetails) => { CommonBase.add_ref_from(ret_hu_conv, first_hops_conv_16); });
715                 CommonBase.add_ref_from(ret_hu_conv, logger);
716                 CommonBase.add_ref_from(ret_hu_conv, scorer);
717                 return ret_hu_conv;
718         }
719
720         /**
721          * Construct a route from us (payer) to the target node (payee) via the given hops (which should
722          * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path.
723          * 
724          * Re-uses logic from `find_route`, so the restrictions described there also apply here.
725          */
726         public static constructor_build_route_from_hops(our_node_pubkey: Uint8Array, hops: Uint8Array[], route_params: RouteParameters, network_graph: NetworkGraph, logger: Logger, random_seed_bytes: Uint8Array): Result_RouteLightningErrorZ {
727                 const ret: number = bindings.build_route_from_hops(bindings.encodeUint8Array(bindings.check_arr_len(our_node_pubkey, 33)), bindings.encodeUint32Array(hops != null ? hops.map(hops_conv_12 => bindings.encodeUint8Array(bindings.check_arr_len(hops_conv_12, 33))) : null), route_params == null ? 0 : CommonBase.get_ptr_of(route_params) & ~1, network_graph == null ? 0 : CommonBase.get_ptr_of(network_graph) & ~1, logger == null ? 0 : CommonBase.get_ptr_of(logger), bindings.encodeUint8Array(bindings.check_arr_len(random_seed_bytes, 32)));
728                 const ret_hu_conv: Result_RouteLightningErrorZ = Result_RouteLightningErrorZ.constr_from_ptr(ret);
729                 CommonBase.add_ref_from(ret_hu_conv, route_params);
730                 CommonBase.add_ref_from(ret_hu_conv, network_graph);
731                 CommonBase.add_ref_from(ret_hu_conv, logger);
732                 return ret_hu_conv;
733         }
734
735         /**
736          * See [`create_invoice_from_channelmanager_with_description_hash`]
737          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
738          * available and the current time is supplied by the caller.
739          */
740         public static constructor_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: ChannelManager, keys_manager: KeysInterface, network: Currency, amt_msat: Option_u64Z, description_hash: Sha256, duration_since_epoch: bigint, invoice_expiry_delta_secs: number): Result_InvoiceSignOrCreationErrorZ {
741                 const ret: number = bindings.create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager == null ? 0 : CommonBase.get_ptr_of(channelmanager) & ~1, keys_manager == null ? 0 : CommonBase.get_ptr_of(keys_manager), network, CommonBase.get_ptr_of(amt_msat), description_hash == null ? 0 : CommonBase.get_ptr_of(description_hash) & ~1, duration_since_epoch, invoice_expiry_delta_secs);
742                 const ret_hu_conv: Result_InvoiceSignOrCreationErrorZ = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
743                 CommonBase.add_ref_from(ret_hu_conv, channelmanager);
744                 CommonBase.add_ref_from(ret_hu_conv, keys_manager);
745                 return ret_hu_conv;
746         }
747
748         /**
749          * See [`create_invoice_from_channelmanager`]
750          * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
751          * available and the current time is supplied by the caller.
752          */
753         public static constructor_create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: ChannelManager, keys_manager: KeysInterface, network: Currency, amt_msat: Option_u64Z, description: string, duration_since_epoch: bigint, invoice_expiry_delta_secs: number): Result_InvoiceSignOrCreationErrorZ {
754                 const ret: number = bindings.create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager == null ? 0 : CommonBase.get_ptr_of(channelmanager) & ~1, keys_manager == null ? 0 : CommonBase.get_ptr_of(keys_manager), network, CommonBase.get_ptr_of(amt_msat), bindings.encodeString(description), duration_since_epoch, invoice_expiry_delta_secs);
755                 const ret_hu_conv: Result_InvoiceSignOrCreationErrorZ = Result_InvoiceSignOrCreationErrorZ.constr_from_ptr(ret);
756                 CommonBase.add_ref_from(ret_hu_conv, channelmanager);
757                 CommonBase.add_ref_from(ret_hu_conv, keys_manager);
758                 return ret_hu_conv;
759         }
760
761 }