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 byte[] get_channel_id() {
29 byte[] ret = bindings.UpdateFee_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
37 public void set_channel_id(byte[] val) {
38 bindings.UpdateFee_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * Fee rate per 1000-weight of the transaction
46 public int get_feerate_per_kw() {
47 int ret = bindings.UpdateFee_get_feerate_per_kw(this.ptr);
48 Reference.reachabilityFence(this);
53 * Fee rate per 1000-weight of the transaction
55 public void set_feerate_per_kw(int val) {
56 bindings.UpdateFee_set_feerate_per_kw(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * Constructs a new UpdateFee given each field
64 public static UpdateFee of(byte[] channel_id_arg, int feerate_per_kw_arg) {
65 long ret = bindings.UpdateFee_new(InternalUtils.check_arr_len(channel_id_arg, 32), feerate_per_kw_arg);
66 Reference.reachabilityFence(channel_id_arg);
67 Reference.reachabilityFence(feerate_per_kw_arg);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
70 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
75 long ret = bindings.UpdateFee_clone_ptr(this.ptr);
76 Reference.reachabilityFence(this);
81 * Creates a copy of the UpdateFee
83 public UpdateFee clone() {
84 long ret = bindings.UpdateFee_clone(this.ptr);
85 Reference.reachabilityFence(this);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
88 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
93 * Checks if two UpdateFees contain equal inner contents.
94 * This ignores pointers and is_owned flags and looks at the values in fields.
95 * Two objects with NULL inner values will be considered "equal" here.
97 public boolean eq(org.ldk.structs.UpdateFee b) {
98 boolean ret = bindings.UpdateFee_eq(this.ptr, b == null ? 0 : b.ptr);
99 Reference.reachabilityFence(this);
100 Reference.reachabilityFence(b);
101 if (this != null) { this.ptrs_to.add(b); };
105 @Override public boolean equals(Object o) {
106 if (!(o instanceof UpdateFee)) return false;
107 return this.eq((UpdateFee)o);
110 * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
112 public byte[] write() {
113 byte[] ret = bindings.UpdateFee_write(this.ptr);
114 Reference.reachabilityFence(this);
119 * Read a UpdateFee from a byte array, created by UpdateFee_write
121 public static Result_UpdateFeeDecodeErrorZ read(byte[] ser) {
122 long ret = bindings.UpdateFee_read(ser);
123 Reference.reachabilityFence(ser);
124 if (ret >= 0 && ret <= 4096) { return null; }
125 Result_UpdateFeeDecodeErrorZ ret_hu_conv = Result_UpdateFeeDecodeErrorZ.constr_from_ptr(ret);