6 namespace org { namespace ldk { namespace structs {
10 * An [`update_fulfill_htlc`] message to be sent to or received from a peer.
12 * [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
14 public class UpdateFulfillHTLC : CommonBase {
15 internal UpdateFulfillHTLC(object _dummy, long ptr) : base(ptr) { }
16 ~UpdateFulfillHTLC() {
17 if (ptr != 0) { bindings.UpdateFulfillHTLC_free(ptr); }
23 public ChannelId get_channel_id() {
24 long ret = bindings.UpdateFulfillHTLC_get_channel_id(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
28 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
35 public void set_channel_id(org.ldk.structs.ChannelId val) {
36 bindings.UpdateFulfillHTLC_set_channel_id(this.ptr, val.ptr);
39 if (this != null) { this.ptrs_to.AddLast(val); };
45 public long get_htlc_id() {
46 long ret = bindings.UpdateFulfillHTLC_get_htlc_id(this.ptr);
54 public void set_htlc_id(long val) {
55 bindings.UpdateFulfillHTLC_set_htlc_id(this.ptr, val);
61 * The pre-image of the payment hash, allowing HTLC redemption
63 public byte[] get_payment_preimage() {
64 long ret = bindings.UpdateFulfillHTLC_get_payment_preimage(this.ptr);
66 if (ret >= 0 && ret <= 4096) { return null; }
67 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
72 * The pre-image of the payment hash, allowing HTLC redemption
74 public void set_payment_preimage(byte[] val) {
75 bindings.UpdateFulfillHTLC_set_payment_preimage(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
81 * Constructs a new UpdateFulfillHTLC given each field
83 public static UpdateFulfillHTLC of(org.ldk.structs.ChannelId channel_id_arg, long htlc_id_arg, byte[] payment_preimage_arg) {
84 long ret = bindings.UpdateFulfillHTLC_new(channel_id_arg.ptr, htlc_id_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage_arg, 32)));
85 GC.KeepAlive(channel_id_arg);
86 GC.KeepAlive(htlc_id_arg);
87 GC.KeepAlive(payment_preimage_arg);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret); }
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
95 internal long clone_ptr() {
96 long ret = bindings.UpdateFulfillHTLC_clone_ptr(this.ptr);
102 * Creates a copy of the UpdateFulfillHTLC
104 public UpdateFulfillHTLC clone() {
105 long ret = bindings.UpdateFulfillHTLC_clone(this.ptr);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.UpdateFulfillHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret); }
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
114 * Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
117 long ret = bindings.UpdateFulfillHTLC_hash(this.ptr);
122 public override int GetHashCode() {
123 return (int)this.hash();
126 * Checks if two UpdateFulfillHTLCs contain equal inner contents.
127 * This ignores pointers and is_owned flags and looks at the values in fields.
128 * Two objects with NULL inner values will be considered "equal" here.
130 public bool eq(org.ldk.structs.UpdateFulfillHTLC b) {
131 bool ret = bindings.UpdateFulfillHTLC_eq(this.ptr, b.ptr);
134 if (this != null) { this.ptrs_to.AddLast(b); };
138 public override bool Equals(object o) {
139 if (!(o is UpdateFulfillHTLC)) return false;
140 return this.eq((UpdateFulfillHTLC)o);
143 * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
145 public byte[] write() {
146 long ret = bindings.UpdateFulfillHTLC_write(this.ptr);
148 if (ret >= 0 && ret <= 4096) { return null; }
149 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
154 * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
156 public static Result_UpdateFulfillHTLCDecodeErrorZ read(byte[] ser) {
157 long ret = bindings.UpdateFulfillHTLC_read(InternalUtils.encodeUint8Array(ser));
159 if (ret >= 0 && ret <= 4096) { return null; }
160 Result_UpdateFulfillHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFulfillHTLCDecodeErrorZ.constr_from_ptr(ret);