X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FNetAddress.mts;fp=ts%2Fstructs%2FNetAddress.mts;h=3b61cb17f2a4e9a01dc82eb3a60c224c6405f8e6;hb=e2bd9223757025980105f0aeb17900f17734b2e3;hp=e64147401d16e2dc7dd348569bf2e01a4c07adfe;hpb=8f5edad2f310a130b658e1b530fe2516724c4d99;p=ldk-java diff --git a/ts/structs/NetAddress.mts b/ts/structs/NetAddress.mts index e6414740..3b61cb17 100644 --- a/ts/structs/NetAddress.mts +++ b/ts/structs/NetAddress.mts @@ -67,6 +67,9 @@ import { Result_PaymentPurposeDecodeErrorZ } from '../structs/Result_PaymentPurp import { ClosureReason } from '../structs/ClosureReason.mjs'; import { Option_ClosureReasonZ } from '../structs/Option_ClosureReasonZ.mjs'; import { Result_COption_ClosureReasonZDecodeErrorZ } from '../structs/Result_COption_ClosureReasonZDecodeErrorZ.mjs'; +import { HTLCDestination } from '../structs/HTLCDestination.mjs'; +import { Option_HTLCDestinationZ } from '../structs/Option_HTLCDestinationZ.mjs'; +import { Result_COption_HTLCDestinationZDecodeErrorZ } from '../structs/Result_COption_HTLCDestinationZDecodeErrorZ.mjs'; import { ChannelUpdate } from '../structs/ChannelUpdate.mjs'; import { NetworkUpdate } from '../structs/NetworkUpdate.mjs'; import { Option_NetworkUpdateZ } from '../structs/Option_NetworkUpdateZ.mjs'; @@ -104,7 +107,7 @@ import { TwoTuple_usizeTransactionZ } from '../structs/TwoTuple_usizeTransaction import { Result_NoneChannelMonitorUpdateErrZ } from '../structs/Result_NoneChannelMonitorUpdateErrZ.mjs'; import { HTLCUpdate } from '../structs/HTLCUpdate.mjs'; import { MonitorEvent } from '../structs/MonitorEvent.mjs'; -import { TwoTuple_OutPointCVec_MonitorEventZZ } from '../structs/TwoTuple_OutPointCVec_MonitorEventZZ.mjs'; +import { ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ } from '../structs/ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ.mjs'; import { Option_C2Tuple_usizeTransactionZZ } from '../structs/Option_C2Tuple_usizeTransactionZZ.mjs'; import { FixedPenaltyScorer } from '../structs/FixedPenaltyScorer.mjs'; import { Result_FixedPenaltyScorerDecodeErrorZ } from '../structs/Result_FixedPenaltyScorerDecodeErrorZ.mjs'; @@ -138,6 +141,7 @@ import { ChannelInfo } from '../structs/ChannelInfo.mjs'; import { Result_ChannelInfoDecodeErrorZ } from '../structs/Result_ChannelInfoDecodeErrorZ.mjs'; import { RoutingFees } from '../structs/RoutingFees.mjs'; import { Result_RoutingFeesDecodeErrorZ } from '../structs/Result_RoutingFeesDecodeErrorZ.mjs'; +import { Hostname } from '../structs/Hostname.mjs'; import { NodeAnnouncementInfo } from '../structs/NodeAnnouncementInfo.mjs'; import { Result_NodeAnnouncementInfoDecodeErrorZ } from '../structs/Result_NodeAnnouncementInfoDecodeErrorZ.mjs'; import { NodeAlias } from '../structs/NodeAlias.mjs'; @@ -364,6 +368,7 @@ export class NetAddress extends CommonBase { case 1: return new NetAddress_IPv6(ptr); case 2: return new NetAddress_OnionV2(ptr); case 3: return new NetAddress_OnionV3(ptr); + case 4: return new NetAddress_Hostname(ptr); default: throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } @@ -424,6 +429,16 @@ export class NetAddress extends CommonBase { return ret_hu_conv; } + /** + * Utility method to constructs a new Hostname-variant NetAddress + */ + public static constructor_hostname(hostname: Hostname, port: number): NetAddress { + const ret: number = bindings.NetAddress_hostname(hostname == null ? 0 : CommonBase.get_ptr_of(hostname) & ~1, port); + const ret_hu_conv: NetAddress = NetAddress.constr_from_ptr(ret); + CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); + return ret_hu_conv; + } + /** * Serialize the NetAddress object into a byte array which can be read by NetAddress_read */ @@ -521,3 +536,23 @@ export class NetAddress_OnionV3 extends NetAddress { this.port = bindings.LDKNetAddress_OnionV3_get_port(ptr); } } +/** A NetAddress of type Hostname */ +export class NetAddress_Hostname extends NetAddress { + /** + * The hostname on which the node is listening. + */ + public hostname: Hostname; + /** + * The port on which the node is listening. + */ + public port: number; + /* @internal */ + public constructor(ptr: number) { + super(null, ptr); + const hostname: number = bindings.LDKNetAddress_Hostname_get_hostname(ptr); + const hostname_hu_conv: Hostname = new Hostname(null, hostname); + CommonBase.add_ref_from(hostname_hu_conv, this); + this.hostname = hostname_hu_conv; + this.port = bindings.LDKNetAddress_Hostname_get_port(ptr); + } +}