9c557d26f350d8bd3598bee00613785030cfc6e4
[ldk-java] / c_sharp / src / org / ldk / structs / SpliceAck.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A splice_ack message to be received by or sent to the splice initiator.
11  */
12 public class SpliceAck : CommonBase {
13         internal SpliceAck(object _dummy, long ptr) : base(ptr) { }
14         ~SpliceAck() {
15                 if (ptr != 0) { bindings.SpliceAck_free(ptr); }
16         }
17
18         /**
19          * The channel ID where splicing is intended
20          */
21         public ChannelId get_channel_id() {
22                 long ret = bindings.SpliceAck_get_channel_id(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
26                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
27                 return ret_hu_conv;
28         }
29
30         /**
31          * The channel ID where splicing is intended
32          */
33         public void set_channel_id(org.ldk.structs.ChannelId val) {
34                 bindings.SpliceAck_set_channel_id(this.ptr, val.ptr);
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37                 if (this != null) { this.ptrs_to.AddLast(val); };
38         }
39
40         /**
41          * The genesis hash of the blockchain where the channel is intended to be spliced
42          */
43         public byte[] get_chain_hash() {
44                 long ret = bindings.SpliceAck_get_chain_hash(this.ptr);
45                 GC.KeepAlive(this);
46                 if (ret >= 0 && ret <= 4096) { return null; }
47                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
48                 return ret_conv;
49         }
50
51         /**
52          * The genesis hash of the blockchain where the channel is intended to be spliced
53          */
54         public void set_chain_hash(byte[] val) {
55                 bindings.SpliceAck_set_chain_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * The intended change in channel capacity: the amount to be added (positive value)
62          * or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
63          */
64         public long get_relative_satoshis() {
65                 long ret = bindings.SpliceAck_get_relative_satoshis(this.ptr);
66                 GC.KeepAlive(this);
67                 return ret;
68         }
69
70         /**
71          * The intended change in channel capacity: the amount to be added (positive value)
72          * or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
73          */
74         public void set_relative_satoshis(long val) {
75                 bindings.SpliceAck_set_relative_satoshis(this.ptr, val);
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(val);
78         }
79
80         /**
81          * The key of the sender (splice acceptor) controlling the new funding transaction
82          */
83         public byte[] get_funding_pubkey() {
84                 long ret = bindings.SpliceAck_get_funding_pubkey(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
88                 return ret_conv;
89         }
90
91         /**
92          * The key of the sender (splice acceptor) controlling the new funding transaction
93          */
94         public void set_funding_pubkey(byte[] val) {
95                 bindings.SpliceAck_set_funding_pubkey(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
96                 GC.KeepAlive(this);
97                 GC.KeepAlive(val);
98         }
99
100         /**
101          * Constructs a new SpliceAck given each field
102          */
103         public static SpliceAck of(org.ldk.structs.ChannelId channel_id_arg, byte[] chain_hash_arg, long relative_satoshis_arg, byte[] funding_pubkey_arg) {
104                 long ret = bindings.SpliceAck_new(channel_id_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), relative_satoshis_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_pubkey_arg, 33)));
105                 GC.KeepAlive(channel_id_arg);
106                 GC.KeepAlive(chain_hash_arg);
107                 GC.KeepAlive(relative_satoshis_arg);
108                 GC.KeepAlive(funding_pubkey_arg);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 org.ldk.structs.SpliceAck ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.SpliceAck(null, ret); }
111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
113                 return ret_hu_conv;
114         }
115
116         internal long clone_ptr() {
117                 long ret = bindings.SpliceAck_clone_ptr(this.ptr);
118                 GC.KeepAlive(this);
119                 return ret;
120         }
121
122         /**
123          * Creates a copy of the SpliceAck
124          */
125         public SpliceAck clone() {
126                 long ret = bindings.SpliceAck_clone(this.ptr);
127                 GC.KeepAlive(this);
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 org.ldk.structs.SpliceAck ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.SpliceAck(null, ret); }
130                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
131                 return ret_hu_conv;
132         }
133
134         /**
135          * Checks if two SpliceAcks contain equal inner contents.
136          * This ignores pointers and is_owned flags and looks at the values in fields.
137          * Two objects with NULL inner values will be considered "equal" here.
138          */
139         public bool eq(org.ldk.structs.SpliceAck b) {
140                 bool ret = bindings.SpliceAck_eq(this.ptr, b.ptr);
141                 GC.KeepAlive(this);
142                 GC.KeepAlive(b);
143                 if (this != null) { this.ptrs_to.AddLast(b); };
144                 return ret;
145         }
146
147         public override bool Equals(object o) {
148                 if (!(o is SpliceAck)) return false;
149                 return this.eq((SpliceAck)o);
150         }
151         /**
152          * Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read
153          */
154         public byte[] write() {
155                 long ret = bindings.SpliceAck_write(this.ptr);
156                 GC.KeepAlive(this);
157                 if (ret >= 0 && ret <= 4096) { return null; }
158                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
159                 return ret_conv;
160         }
161
162         /**
163          * Read a SpliceAck from a byte array, created by SpliceAck_write
164          */
165         public static Result_SpliceAckDecodeErrorZ read(byte[] ser) {
166                 long ret = bindings.SpliceAck_read(InternalUtils.encodeUint8Array(ser));
167                 GC.KeepAlive(ser);
168                 if (ret >= 0 && ret <= 4096) { return null; }
169                 Result_SpliceAckDecodeErrorZ ret_hu_conv = Result_SpliceAckDecodeErrorZ.constr_from_ptr(ret);
170                 return ret_hu_conv;
171         }
172
173 }
174 } } }