X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FEvent.ts;h=36a548c89d7e5d287e7cdeb29202b92fa35c632e;hb=c6bac88847b7c09560af81f00ba8dd3c2ebe3a19;hp=db05d8ae2fe3dd3f57a1937900f9e11658f3d10b;hpb=a7653cf8717b1f9df4d3f4c4bd0b1f50f3bbc230;p=ldk-java diff --git a/ts/structs/Event.ts b/ts/structs/Event.ts index db05d8ae..36a548c8 100644 --- a/ts/structs/Event.ts +++ b/ts/structs/Event.ts @@ -34,6 +34,9 @@ export default class Event extends CommonBase { if (raw_val instanceof bindings.LDKEvent.ChannelClosed) { return new ChannelClosed(this.ptr, raw_val); } + if (raw_val instanceof bindings.LDKEvent.DiscardFunding) { + return new DiscardFunding(this.ptr, raw_val); + } throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } @@ -66,20 +69,33 @@ export class PaymentReceived extends Event { } } export class PaymentSent extends Event { + public payment_id: Uint8Array; public payment_preimage: Uint8Array; + public payment_hash: Uint8Array; + public fee_paid_msat: Option_u64Z; private constructor(ptr: number, obj: bindings.LDKEvent.PaymentSent) { super(null, ptr); + this.payment_id = obj.payment_id; this.payment_preimage = obj.payment_preimage; + this.payment_hash = obj.payment_hash; + const fee_paid_msat: number = obj.fee_paid_msat; + Option_u64Z fee_paid_msat_hu_conv = Option_u64Z.constr_from_ptr(fee_paid_msat); + fee_paid_msat_hu_conv.ptrs_to.add(this); + this.fee_paid_msat = fee_paid_msat_hu_conv; } } export class PaymentPathFailed extends Event { + public payment_id: Uint8Array; public payment_hash: Uint8Array; public rejected_by_dest: boolean; public network_update: Option_NetworkUpdateZ; public all_paths_failed: boolean; public path: RouteHop[]; + public short_channel_id: Option_u64Z; + public retry: RouteParameters; private constructor(ptr: number, obj: bindings.LDKEvent.PaymentPathFailed) { super(null, ptr); + this.payment_id = obj.payment_id; this.payment_hash = obj.payment_hash; this.rejected_by_dest = obj.rejected_by_dest; const network_update: number = obj.network_update; @@ -96,6 +112,14 @@ export class PaymentPathFailed extends Event { path_conv_10_arr[k] = path_conv_10_hu_conv; } this.path = path_conv_10_arr; + const short_channel_id: number = obj.short_channel_id; + Option_u64Z short_channel_id_hu_conv = Option_u64Z.constr_from_ptr(short_channel_id); + short_channel_id_hu_conv.ptrs_to.add(this); + this.short_channel_id = short_channel_id_hu_conv; + const retry: number = obj.retry; + const retry_hu_conv: RouteParameters = new RouteParameters(null, retry); + retry_hu_conv.ptrs_to.add(this); + this.retry = retry_hu_conv; } } export class PendingHTLCsForwardable extends Event { @@ -134,15 +158,26 @@ export class PaymentForwarded extends Event { } export class ChannelClosed extends Event { public channel_id: Uint8Array; + public user_channel_id: number; public reason: ClosureReason; private constructor(ptr: number, obj: bindings.LDKEvent.ChannelClosed) { super(null, ptr); this.channel_id = obj.channel_id; + this.user_channel_id = obj.user_channel_id; const reason: number = obj.reason; ClosureReason reason_hu_conv = ClosureReason.constr_from_ptr(reason); reason_hu_conv.ptrs_to.add(this); this.reason = reason_hu_conv; } +} +export class DiscardFunding extends Event { + public channel_id: Uint8Array; + public transaction: Uint8Array; + private constructor(ptr: number, obj: bindings.LDKEvent.DiscardFunding) { + super(null, ptr); + this.channel_id = obj.channel_id; + this.transaction = obj.transaction; + } } public Event clone() { number ret = bindings.Event_clone(this.ptr); @@ -165,18 +200,17 @@ export class ChannelClosed extends Event { return ret_hu_conv; } - public static Event constructor_payment_sent(Uint8Array payment_preimage) { - number ret = bindings.Event_payment_sent(payment_preimage); + public static Event constructor_payment_sent(Uint8Array payment_id, Uint8Array payment_preimage, Uint8Array payment_hash, Option_u64Z fee_paid_msat) { + number ret = bindings.Event_payment_sent(payment_id, payment_preimage, payment_hash, fee_paid_msat.ptr); Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } - public static Event constructor_payment_path_failed(Uint8Array payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path) { - number ret = bindings.Event_payment_path_failed(payment_hash, rejected_by_dest, network_update.ptr, all_paths_failed, path != null ? Arrays.stream(path).map(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray(number[]::new) : null); + public static Event constructor_payment_path_failed(Uint8Array payment_id, Uint8Array payment_hash, boolean rejected_by_dest, Option_NetworkUpdateZ network_update, boolean all_paths_failed, RouteHop[] path, Option_u64Z short_channel_id, RouteParameters retry) { + number ret = bindings.Event_payment_path_failed(payment_id, payment_hash, rejected_by_dest, network_update.ptr, all_paths_failed, path != null ? Arrays.stream(path).map(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray(number[]::new) : null, short_channel_id.ptr, retry == null ? 0 : retry.ptr & ~1); Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - for (RouteHop path_conv_10: path) { ret_hu_conv.ptrs_to.add(path_conv_10); }; return ret_hu_conv; } @@ -201,8 +235,15 @@ export class ChannelClosed extends Event { return ret_hu_conv; } - public static Event constructor_channel_closed(Uint8Array channel_id, ClosureReason reason) { - number ret = bindings.Event_channel_closed(channel_id, reason.ptr); + public static Event constructor_channel_closed(Uint8Array channel_id, number user_channel_id, ClosureReason reason) { + number ret = bindings.Event_channel_closed(channel_id, user_channel_id, reason.ptr); + Event ret_hu_conv = Event.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static Event constructor_discard_funding(Uint8Array channel_id, Uint8Array transaction) { + number ret = bindings.Event_discard_funding(channel_id, transaction); Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv;