[TS] Update auto-generated bindings to LDK 0.0.118
[ldk-java] / ts / structs / CustomOnionMessageHandler.mts
index d4d3243b4c1a641126b5a915c5c848b1e65ddc31..422bddb0b07d44e72483b1c5f1ead787c0cc6a2a 100644 (file)
@@ -52,6 +52,10 @@ import { Result_SpendableOutputDescriptorDecodeErrorZ } from '../structs/Result_
 import { Option_u32Z } from '../structs/Option_u32Z.mjs';
 import { TwoTuple_CVec_u8ZusizeZ } from '../structs/TwoTuple_CVec_u8ZusizeZ.mjs';
 import { Result_C2Tuple_CVec_u8ZusizeZNoneZ } from '../structs/Result_C2Tuple_CVec_u8ZusizeZNoneZ.mjs';
+import { ChannelDerivationParameters } from '../structs/ChannelDerivationParameters.mjs';
+import { Result_ChannelDerivationParametersDecodeErrorZ } from '../structs/Result_ChannelDerivationParametersDecodeErrorZ.mjs';
+import { HTLCDescriptor } from '../structs/HTLCDescriptor.mjs';
+import { Result_HTLCDescriptorDecodeErrorZ } from '../structs/Result_HTLCDescriptorDecodeErrorZ.mjs';
 import { Result_NoneNoneZ } from '../structs/Result_NoneNoneZ.mjs';
 import { TwoTuple_ECDSASignatureCVec_ECDSASignatureZZ } from '../structs/TwoTuple_ECDSASignatureCVec_ECDSASignatureZZ.mjs';
 import { Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ } from '../structs/Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ.mjs';
@@ -63,7 +67,6 @@ import { Result_SchnorrSignatureNoneZ } from '../structs/Result_SchnorrSignature
 import { CommitmentTransaction } from '../structs/CommitmentTransaction.mjs';
 import { HolderCommitmentTransaction } from '../structs/HolderCommitmentTransaction.mjs';
 import { HTLCOutputInCommitment } from '../structs/HTLCOutputInCommitment.mjs';
-import { HTLCDescriptor } from '../structs/HTLCDescriptor.mjs';
 import { ClosingTransaction } from '../structs/ClosingTransaction.mjs';
 import { UnsignedChannelAnnouncement } from '../structs/UnsignedChannelAnnouncement.mjs';
 import { ChannelPublicKeys } from '../structs/ChannelPublicKeys.mjs';
@@ -201,9 +204,6 @@ import { NodeInfo } from '../structs/NodeInfo.mjs';
 import { Result_NodeInfoDecodeErrorZ } from '../structs/Result_NodeInfoDecodeErrorZ.mjs';
 import { Result_NetworkGraphDecodeErrorZ } from '../structs/Result_NetworkGraphDecodeErrorZ.mjs';
 import { Option_CVec_SocketAddressZZ } from '../structs/Option_CVec_SocketAddressZZ.mjs';
-import { ChannelDerivationParameters } from '../structs/ChannelDerivationParameters.mjs';
-import { Result_ChannelDerivationParametersDecodeErrorZ } from '../structs/Result_ChannelDerivationParametersDecodeErrorZ.mjs';
-import { Result_HTLCDescriptorDecodeErrorZ } from '../structs/Result_HTLCDescriptorDecodeErrorZ.mjs';
 import { Utxo } from '../structs/Utxo.mjs';
 import { Option_TxOutZ } from '../structs/Option_TxOutZ.mjs';
 import { Input } from '../structs/Input.mjs';
@@ -225,7 +225,16 @@ import { Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ } from
 import { ProbeSendFailure } from '../structs/ProbeSendFailure.mjs';
 import { Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ } from '../structs/Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.mjs';
 import { TwoTuple_ThirtyTwoBytesPublicKeyZ } from '../structs/TwoTuple_ThirtyTwoBytesPublicKeyZ.mjs';
+import { Option_StrZ } from '../structs/Option_StrZ.mjs';
+import { Result_NoneBolt12SemanticErrorZ } from '../structs/Result_NoneBolt12SemanticErrorZ.mjs';
 import { Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.mjs';
+import { InvoiceRequest } from '../structs/InvoiceRequest.mjs';
+import { Bolt12Invoice } from '../structs/Bolt12Invoice.mjs';
+import { InvoiceError } from '../structs/InvoiceError.mjs';
+import { OffersMessage } from '../structs/OffersMessage.mjs';
+import { Option_OffersMessageZ } from '../structs/Option_OffersMessageZ.mjs';
+import { Destination } from '../structs/Destination.mjs';
+import { ThreeTuple_OffersMessageDestinationBlindedPathZ } from '../structs/ThreeTuple_OffersMessageDestinationBlindedPathZ.mjs';
 import { CounterpartyForwardingInfo } from '../structs/CounterpartyForwardingInfo.mjs';
 import { Result_CounterpartyForwardingInfoDecodeErrorZ } from '../structs/Result_CounterpartyForwardingInfoDecodeErrorZ.mjs';
 import { ChannelCounterparty } from '../structs/ChannelCounterparty.mjs';
@@ -272,14 +281,10 @@ import { TwoTuple_ThirtyTwoBytesChannelMonitorZ } from '../structs/TwoTuple_Thir
 import { Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ } from '../structs/Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.mjs';
 import { Type, TypeInterface } from '../structs/Type.mjs';
 import { TwoTuple_PublicKeyTypeZ } from '../structs/TwoTuple_PublicKeyTypeZ.mjs';
-import { InvoiceRequest } from '../structs/InvoiceRequest.mjs';
-import { Bolt12Invoice } from '../structs/Bolt12Invoice.mjs';
-import { InvoiceError } from '../structs/InvoiceError.mjs';
-import { OffersMessage } from '../structs/OffersMessage.mjs';
-import { Option_OffersMessageZ } from '../structs/Option_OffersMessageZ.mjs';
-import { CustomOnionMessageContents, CustomOnionMessageContentsInterface } from '../structs/CustomOnionMessageContents.mjs';
-import { Option_CustomOnionMessageContentsZ } from '../structs/Option_CustomOnionMessageContentsZ.mjs';
-import { Result_COption_CustomOnionMessageContentsZDecodeErrorZ } from '../structs/Result_COption_CustomOnionMessageContentsZDecodeErrorZ.mjs';
+import { OnionMessageContents, OnionMessageContentsInterface } from '../structs/OnionMessageContents.mjs';
+import { Option_OnionMessageContentsZ } from '../structs/Option_OnionMessageContentsZ.mjs';
+import { Result_COption_OnionMessageContentsZDecodeErrorZ } from '../structs/Result_COption_OnionMessageContentsZDecodeErrorZ.mjs';
+import { ThreeTuple_OnionMessageContentsDestinationBlindedPathZ } from '../structs/ThreeTuple_OnionMessageContentsDestinationBlindedPathZ.mjs';
 import { Option_TypeZ } from '../structs/Option_TypeZ.mjs';
 import { Result_COption_TypeZDecodeErrorZ } from '../structs/Result_COption_TypeZDecodeErrorZ.mjs';
 import { Option_SocketAddressZ } from '../structs/Option_SocketAddressZ.mjs';
@@ -451,6 +456,9 @@ import { Result_OnionMessagePathNoneZ } from '../structs/Result_OnionMessagePath
 import { TwoTuple_PublicKeyOnionMessageZ } from '../structs/TwoTuple_PublicKeyOnionMessageZ.mjs';
 import { SendError } from '../structs/SendError.mjs';
 import { Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ } from '../structs/Result_C2Tuple_PublicKeyOnionMessageZSendErrorZ.mjs';
+import { ParsedOnionMessageContents } from '../structs/ParsedOnionMessageContents.mjs';
+import { PeeledOnion } from '../structs/PeeledOnion.mjs';
+import { Result_PeeledOnionNoneZ } from '../structs/Result_PeeledOnionNoneZ.mjs';
 import { Result_NoneSendErrorZ } from '../structs/Result_NoneSendErrorZ.mjs';
 import { Result_BlindedPathNoneZ } from '../structs/Result_BlindedPathNoneZ.mjs';
 import { Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ } from '../structs/Result_C2Tuple_BlindedPayInfoBlindedPathZNoneZ.mjs';
@@ -491,16 +499,15 @@ import { FailureCode } from '../structs/FailureCode.mjs';
 import { ChainParameters } from '../structs/ChainParameters.mjs';
 import { MessageSendEventsProvider, MessageSendEventsProviderInterface } from '../structs/MessageSendEventsProvider.mjs';
 import { ChannelMessageHandler, ChannelMessageHandlerInterface } from '../structs/ChannelMessageHandler.mjs';
+import { OffersMessageHandler, OffersMessageHandlerInterface } from '../structs/OffersMessageHandler.mjs';
 import { ChannelManagerReadArgs } from '../structs/ChannelManagerReadArgs.mjs';
 import { ExpandedKey } from '../structs/ExpandedKey.mjs';
 import { Packet } from '../structs/Packet.mjs';
 import { RoutingMessageHandler, RoutingMessageHandlerInterface } from '../structs/RoutingMessageHandler.mjs';
-import { OnionMessageProvider, OnionMessageProviderInterface } from '../structs/OnionMessageProvider.mjs';
 import { OnionMessageHandler, OnionMessageHandlerInterface } from '../structs/OnionMessageHandler.mjs';
 import { CustomMessageReader, CustomMessageReaderInterface } from '../structs/CustomMessageReader.mjs';
 import { CustomMessageHandler, CustomMessageHandlerInterface } from '../structs/CustomMessageHandler.mjs';
 import { IgnoringMessageHandler } from '../structs/IgnoringMessageHandler.mjs';
-import { OffersMessageHandler, OffersMessageHandlerInterface } from '../structs/OffersMessageHandler.mjs';
 import { ErroringMessageHandler } from '../structs/ErroringMessageHandler.mjs';
 import { MessageHandler } from '../structs/MessageHandler.mjs';
 import { SocketDescriptor, SocketDescriptorInterface } from '../structs/SocketDescriptor.mjs';
@@ -526,11 +533,9 @@ import { MultiThreadedScoreLockWrite } from '../structs/MultiThreadedScoreLockWr
 import { ProbabilisticScoringDecayParameters } from '../structs/ProbabilisticScoringDecayParameters.mjs';
 import { KeysManager } from '../structs/KeysManager.mjs';
 import { PhantomKeysManager } from '../structs/PhantomKeysManager.mjs';
-import { Destination } from '../structs/Destination.mjs';
 import { MessageRouter, MessageRouterInterface } from '../structs/MessageRouter.mjs';
 import { OnionMessenger } from '../structs/OnionMessenger.mjs';
 import { DefaultMessageRouter } from '../structs/DefaultMessageRouter.mjs';
-import { OnionMessageContents } from '../structs/OnionMessageContents.mjs';
 import { ForwardNode } from '../structs/ForwardNode.mjs';
 import { ForwardTlvs } from '../structs/ForwardTlvs.mjs';
 import { CoinSelectionSource, CoinSelectionSourceInterface } from '../structs/CoinSelectionSource.mjs';
@@ -554,12 +559,20 @@ import * as bindings from '../bindings.mjs'
 /** An implementation of CustomOnionMessageHandler */
 export interface CustomOnionMessageHandlerInterface {
        /**Called with the custom message that was received, returning a response to send, if any.
+        * 
+        * The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`].
         */
-       handle_custom_message(msg: CustomOnionMessageContents): Option_CustomOnionMessageContentsZ;
+       handle_custom_message(msg: OnionMessageContents): Option_OnionMessageContentsZ;
        /**Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the
         * message type is unknown.
         */
-       read_custom_message(message_type: bigint, buffer: Uint8Array): Result_COption_CustomOnionMessageContentsZDecodeErrorZ;
+       read_custom_message(message_type: bigint, buffer: Uint8Array): Result_COption_OnionMessageContentsZDecodeErrorZ;
+       /**Releases any [`Self::CustomMessage`]s that need to be sent.
+        * 
+        * Typically, this is used for messages initiating a message flow rather than in response to
+        * another message. The latter should use the return value of [`Self::handle_custom_message`].
+        */
+       release_pending_custom_messages(): ThreeTuple_OnionMessageContentsDestinationBlindedPathZ[];
 }
 
 class LDKCustomOnionMessageHandlerHolder {
@@ -596,19 +609,24 @@ export class CustomOnionMessageHandler extends CommonBase {
                const impl_holder: LDKCustomOnionMessageHandlerHolder = new LDKCustomOnionMessageHandlerHolder();
                let structImplementation = {
                        handle_custom_message (msg: bigint): bigint {
-                               const ret_hu_conv: CustomOnionMessageContents = new CustomOnionMessageContents(null, msg);
+                               const ret_hu_conv: OnionMessageContents = new OnionMessageContents(null, msg);
                                CommonBase.add_ref_from(ret_hu_conv, this);
-                               const ret: Option_CustomOnionMessageContentsZ = arg.handle_custom_message(ret_hu_conv);
+                               const ret: Option_OnionMessageContentsZ = arg.handle_custom_message(ret_hu_conv);
                                const result: bigint = ret == null ? 0n : ret.clone_ptr();
                                CommonBase.add_ref_from(impl_holder.held, ret);
                                return result;
                        },
                        read_custom_message (message_type: bigint, buffer: number): bigint {
                                const buffer_conv: Uint8Array = bindings.decodeUint8Array(buffer);
-                               const ret: Result_COption_CustomOnionMessageContentsZDecodeErrorZ = arg.read_custom_message(message_type, buffer_conv);
+                               const ret: Result_COption_OnionMessageContentsZDecodeErrorZ = arg.read_custom_message(message_type, buffer_conv);
                                const result: bigint = ret == null ? 0n : ret.clone_ptr();
                                return result;
                        },
+                       release_pending_custom_messages (): number {
+                               const ret: ThreeTuple_OnionMessageContentsDestinationBlindedPathZ[] = arg.release_pending_custom_messages();
+                               const result: number = bindings.encodeUint64Array(ret.map(ret_conv_56 => ret_conv_56 == null ? 0n : ret_conv_56.clone_ptr()));
+                               return result;
+                       },
                } as bindings.LDKCustomOnionMessageHandler;
                const ptr_idx: [bigint, number] = bindings.LDKCustomOnionMessageHandler_new(structImplementation);
 
@@ -620,10 +638,12 @@ export class CustomOnionMessageHandler extends CommonBase {
 
        /**
         * Called with the custom message that was received, returning a response to send, if any.
+        * 
+        * The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`].
         */
-       public handle_custom_message(msg: CustomOnionMessageContents): Option_CustomOnionMessageContentsZ {
+       public handle_custom_message(msg: OnionMessageContents): Option_OnionMessageContentsZ {
                const ret: bigint = bindings.CustomOnionMessageHandler_handle_custom_message(this.ptr, CommonBase.get_ptr_of(msg));
-               const ret_hu_conv: Option_CustomOnionMessageContentsZ = Option_CustomOnionMessageContentsZ.constr_from_ptr(ret);
+               const ret_hu_conv: Option_OnionMessageContentsZ = Option_OnionMessageContentsZ.constr_from_ptr(ret);
                CommonBase.add_ref_from(ret_hu_conv, this);
                CommonBase.add_ref_from(this, msg);
                return ret_hu_conv;
@@ -633,10 +653,30 @@ export class CustomOnionMessageHandler extends CommonBase {
         * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the
         * message type is unknown.
         */
-       public read_custom_message(message_type: bigint, buffer: Uint8Array): Result_COption_CustomOnionMessageContentsZDecodeErrorZ {
+       public read_custom_message(message_type: bigint, buffer: Uint8Array): Result_COption_OnionMessageContentsZDecodeErrorZ {
                const ret: bigint = bindings.CustomOnionMessageHandler_read_custom_message(this.ptr, message_type, bindings.encodeUint8Array(buffer));
-               const ret_hu_conv: Result_COption_CustomOnionMessageContentsZDecodeErrorZ = Result_COption_CustomOnionMessageContentsZDecodeErrorZ.constr_from_ptr(ret);
+               const ret_hu_conv: Result_COption_OnionMessageContentsZDecodeErrorZ = Result_COption_OnionMessageContentsZDecodeErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
 
+       /**
+        * Releases any [`Self::CustomMessage`]s that need to be sent.
+        * 
+        * Typically, this is used for messages initiating a message flow rather than in response to
+        * another message. The latter should use the return value of [`Self::handle_custom_message`].
+        */
+       public release_pending_custom_messages(): ThreeTuple_OnionMessageContentsDestinationBlindedPathZ[] {
+               const ret: number = bindings.CustomOnionMessageHandler_release_pending_custom_messages(this.ptr);
+               const ret_conv_56_len: number = bindings.getArrayLength(ret);
+               const ret_conv_56_arr: ThreeTuple_OnionMessageContentsDestinationBlindedPathZ[] = new Array(ret_conv_56_len).fill(null);
+               for (var e = 0; e < ret_conv_56_len; e++) {
+                       const ret_conv_56: bigint = bindings.getU64ArrayElem(ret, e);
+                       const ret_conv_56_hu_conv: ThreeTuple_OnionMessageContentsDestinationBlindedPathZ = new ThreeTuple_OnionMessageContentsDestinationBlindedPathZ(null, ret_conv_56);
+                       CommonBase.add_ref_from(ret_conv_56_hu_conv, this);
+                       ret_conv_56_arr[e] = ret_conv_56_hu_conv;
+               }
+               bindings.freeWasmMemory(ret)
+               return ret_conv_56_arr;
+       }
+
 }