1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * An [`update_fee`] message to be sent to or received from a peer
14 * [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UpdateFee extends CommonBase {
18 UpdateFee(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.UpdateFee_free(ptr); }
28 public ChannelId get_channel_id() {
29 long ret = bindings.UpdateFee_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
40 public void set_channel_id(org.ldk.structs.ChannelId val) {
41 bindings.UpdateFee_set_channel_id(this.ptr, val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
48 * Fee rate per 1000-weight of the transaction
50 public int get_feerate_per_kw() {
51 int ret = bindings.UpdateFee_get_feerate_per_kw(this.ptr);
52 Reference.reachabilityFence(this);
57 * Fee rate per 1000-weight of the transaction
59 public void set_feerate_per_kw(int val) {
60 bindings.UpdateFee_set_feerate_per_kw(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * Constructs a new UpdateFee given each field
68 public static UpdateFee of(org.ldk.structs.ChannelId channel_id_arg, int feerate_per_kw_arg) {
69 long ret = bindings.UpdateFee_new(channel_id_arg.ptr, feerate_per_kw_arg);
70 Reference.reachabilityFence(channel_id_arg);
71 Reference.reachabilityFence(feerate_per_kw_arg);
72 if (ret >= 0 && ret <= 4096) { return null; }
73 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
75 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
80 long ret = bindings.UpdateFee_clone_ptr(this.ptr);
81 Reference.reachabilityFence(this);
86 * Creates a copy of the UpdateFee
88 public UpdateFee clone() {
89 long ret = bindings.UpdateFee_clone(this.ptr);
90 Reference.reachabilityFence(this);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
98 * Generates a non-cryptographic 64-bit hash of the UpdateFee.
101 long ret = bindings.UpdateFee_hash(this.ptr);
102 Reference.reachabilityFence(this);
106 @Override public int hashCode() {
107 return (int)this.hash();
110 * Checks if two UpdateFees contain equal inner contents.
111 * This ignores pointers and is_owned flags and looks at the values in fields.
112 * Two objects with NULL inner values will be considered "equal" here.
114 public boolean eq(org.ldk.structs.UpdateFee b) {
115 boolean ret = bindings.UpdateFee_eq(this.ptr, b.ptr);
116 Reference.reachabilityFence(this);
117 Reference.reachabilityFence(b);
118 if (this != null) { this.ptrs_to.add(b); };
122 @Override public boolean equals(Object o) {
123 if (!(o instanceof UpdateFee)) return false;
124 return this.eq((UpdateFee)o);
127 * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
129 public byte[] write() {
130 byte[] ret = bindings.UpdateFee_write(this.ptr);
131 Reference.reachabilityFence(this);
136 * Read a UpdateFee from a byte array, created by UpdateFee_write
138 public static Result_UpdateFeeDecodeErrorZ read(byte[] ser) {
139 long ret = bindings.UpdateFee_read(ser);
140 Reference.reachabilityFence(ser);
141 if (ret >= 0 && ret <= 4096) { return null; }
142 Result_UpdateFeeDecodeErrorZ ret_hu_conv = Result_UpdateFeeDecodeErrorZ.constr_from_ptr(ret);