X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FEvent.ts;h=a21ecbf320f8ac779a08f47cdf8194e8912dc8c2;hb=1854b5cebef22ace9e9e4dd191f609818df9ce08;hp=c8374a2b73f273a2afecb9008d24d96acbe6353f;hpb=9d146759e11191b55130be7a1b6988d3f289a168;p=ldk-java diff --git a/ts/structs/Event.ts b/ts/structs/Event.ts index c8374a2b..a21ecbf3 100644 --- a/ts/structs/Event.ts +++ b/ts/structs/Event.ts @@ -22,6 +22,9 @@ export default class Event extends CommonBase { if (raw_val instanceof bindings.LDKEvent.PaymentPathFailed) { return new PaymentPathFailed(this.ptr, raw_val); } + if (raw_val instanceof bindings.LDKEvent.PaymentFailed) { + return new PaymentFailed(this.ptr, raw_val); + } if (raw_val instanceof bindings.LDKEvent.PendingHTLCsForwardable) { return new PendingHTLCsForwardable(this.ptr, raw_val); } @@ -34,6 +37,12 @@ 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); + } + if (raw_val instanceof bindings.LDKEvent.PaymentPathSuccessful) { + return new PaymentPathSuccessful(this.ptr, raw_val); + } throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } @@ -66,20 +75,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 +118,23 @@ 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 PaymentFailed extends Event { + public payment_id: Uint8Array; + public payment_hash: Uint8Array; + private constructor(ptr: number, obj: bindings.LDKEvent.PaymentFailed) { + super(null, ptr); + this.payment_id = obj.payment_id; + this.payment_hash = obj.payment_hash; } } export class PendingHTLCsForwardable extends Event { @@ -134,16 +173,51 @@ 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; + } +} +export class PaymentPathSuccessful extends Event { + public payment_id: Uint8Array; + public payment_hash: Uint8Array; + public path: RouteHop[]; + private constructor(ptr: number, obj: bindings.LDKEvent.PaymentPathSuccessful) { + super(null, ptr); + this.payment_id = obj.payment_id; + this.payment_hash = obj.payment_hash; + const path: number[] = obj.path; + RouteHop[] path_conv_10_arr = new RouteHop[path.length]; + for (int k = 0; k < path.length; k++) { + number path_conv_10 = path[k]; + const path_conv_10_hu_conv: RouteHop = new RouteHop(null, path_conv_10); + path_conv_10_hu_conv.ptrs_to.add(this); + path_conv_10_arr[k] = path_conv_10_hu_conv; + } + this.path = path_conv_10_arr; + } +} + public number clone_ptr() { + number ret = bindings.Event_clone_ptr(this.ptr); + return ret; + } + public Event clone() { number ret = bindings.Event_clone(this.ptr); Event ret_hu_conv = Event.constr_from_ptr(ret); @@ -152,28 +226,35 @@ export class ChannelClosed extends Event { } public static Event constructor_funding_generation_ready(Uint8Array temporary_channel_id, number channel_value_satoshis, Uint8Array output_script, number user_channel_id) { - number ret = bindings.Event_funding_generation_ready(temporary_channel_id, channel_value_satoshis, output_script, user_channel_id); + number ret = bindings.Event_funding_generation_ready(InternalUtils.check_arr_len(temporary_channel_id, 32), channel_value_satoshis, output_script, user_channel_id); 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_received(Uint8Array payment_hash, number amt, PaymentPurpose purpose) { - number ret = bindings.Event_payment_received(payment_hash, amt, purpose.ptr); + number ret = bindings.Event_payment_received(InternalUtils.check_arr_len(payment_hash, 32), amt, purpose.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_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(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_hash, 32), 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(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), 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); + return ret_hu_conv; + } + + public static Event constructor_payment_failed(Uint8Array payment_id, Uint8Array payment_hash) { + number ret = bindings.Event_payment_failed(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32)); Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; @@ -200,8 +281,22 @@ 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(InternalUtils.check_arr_len(channel_id, 32), 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(InternalUtils.check_arr_len(channel_id, 32), transaction); + 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_successful(Uint8Array payment_id, Uint8Array payment_hash, RouteHop[] path) { + number ret = bindings.Event_payment_path_successful(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), path != null ? Arrays.stream(path).map(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray(number[]::new) : null); Event ret_hu_conv = Event.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv;