e87ab57d405da5b1eaf9fd178e3e1e7fd55cc43f
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelAnnouncement.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 channel_announcement message to be sent or received from a peer
11  */
12 public class ChannelAnnouncement : CommonBase {
13         internal ChannelAnnouncement(object _dummy, long ptr) : base(ptr) { }
14         ~ChannelAnnouncement() {
15                 if (ptr != 0) { bindings.ChannelAnnouncement_free(ptr); }
16         }
17
18         /**
19          * Authentication of the announcement by the first public node
20          */
21         public byte[] get_node_signature_1() {
22                 byte[] ret = bindings.ChannelAnnouncement_get_node_signature_1(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * Authentication of the announcement by the first public node
29          */
30         public void set_node_signature_1(byte[] val) {
31                 bindings.ChannelAnnouncement_set_node_signature_1(this.ptr, InternalUtils.check_arr_len(val, 64));
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * Authentication of the announcement by the second public node
38          */
39         public byte[] get_node_signature_2() {
40                 byte[] ret = bindings.ChannelAnnouncement_get_node_signature_2(this.ptr);
41                 GC.KeepAlive(this);
42                 return ret;
43         }
44
45         /**
46          * Authentication of the announcement by the second public node
47          */
48         public void set_node_signature_2(byte[] val) {
49                 bindings.ChannelAnnouncement_set_node_signature_2(this.ptr, InternalUtils.check_arr_len(val, 64));
50                 GC.KeepAlive(this);
51                 GC.KeepAlive(val);
52         }
53
54         /**
55          * Proof of funding UTXO ownership by the first public node
56          */
57         public byte[] get_bitcoin_signature_1() {
58                 byte[] ret = bindings.ChannelAnnouncement_get_bitcoin_signature_1(this.ptr);
59                 GC.KeepAlive(this);
60                 return ret;
61         }
62
63         /**
64          * Proof of funding UTXO ownership by the first public node
65          */
66         public void set_bitcoin_signature_1(byte[] val) {
67                 bindings.ChannelAnnouncement_set_bitcoin_signature_1(this.ptr, InternalUtils.check_arr_len(val, 64));
68                 GC.KeepAlive(this);
69                 GC.KeepAlive(val);
70         }
71
72         /**
73          * Proof of funding UTXO ownership by the second public node
74          */
75         public byte[] get_bitcoin_signature_2() {
76                 byte[] ret = bindings.ChannelAnnouncement_get_bitcoin_signature_2(this.ptr);
77                 GC.KeepAlive(this);
78                 return ret;
79         }
80
81         /**
82          * Proof of funding UTXO ownership by the second public node
83          */
84         public void set_bitcoin_signature_2(byte[] val) {
85                 bindings.ChannelAnnouncement_set_bitcoin_signature_2(this.ptr, InternalUtils.check_arr_len(val, 64));
86                 GC.KeepAlive(this);
87                 GC.KeepAlive(val);
88         }
89
90         /**
91          * The actual announcement
92          */
93         public UnsignedChannelAnnouncement get_contents() {
94                 long ret = bindings.ChannelAnnouncement_get_contents(this.ptr);
95                 GC.KeepAlive(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, ret); }
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * The actual announcement
104          */
105         public void set_contents(org.ldk.structs.UnsignedChannelAnnouncement val) {
106                 bindings.ChannelAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr);
107                 GC.KeepAlive(this);
108                 GC.KeepAlive(val);
109                 if (this != null) { this.ptrs_to.AddLast(val); };
110         }
111
112         /**
113          * Constructs a new ChannelAnnouncement given each field
114          */
115         public static ChannelAnnouncement of(byte[] node_signature_1_arg, byte[] node_signature_2_arg, byte[] bitcoin_signature_1_arg, byte[] bitcoin_signature_2_arg, org.ldk.structs.UnsignedChannelAnnouncement contents_arg) {
116                 long ret = bindings.ChannelAnnouncement_new(InternalUtils.check_arr_len(node_signature_1_arg, 64), InternalUtils.check_arr_len(node_signature_2_arg, 64), InternalUtils.check_arr_len(bitcoin_signature_1_arg, 64), InternalUtils.check_arr_len(bitcoin_signature_2_arg, 64), contents_arg == null ? 0 : contents_arg.ptr);
117                 GC.KeepAlive(node_signature_1_arg);
118                 GC.KeepAlive(node_signature_2_arg);
119                 GC.KeepAlive(bitcoin_signature_1_arg);
120                 GC.KeepAlive(bitcoin_signature_2_arg);
121                 GC.KeepAlive(contents_arg);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); }
124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(contents_arg); };
126                 return ret_hu_conv;
127         }
128
129         internal long clone_ptr() {
130                 long ret = bindings.ChannelAnnouncement_clone_ptr(this.ptr);
131                 GC.KeepAlive(this);
132                 return ret;
133         }
134
135         /**
136          * Creates a copy of the ChannelAnnouncement
137          */
138         public ChannelAnnouncement clone() {
139                 long ret = bindings.ChannelAnnouncement_clone(this.ptr);
140                 GC.KeepAlive(this);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); }
143                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
144                 return ret_hu_conv;
145         }
146
147         /**
148          * Checks if two ChannelAnnouncements contain equal inner contents.
149          * This ignores pointers and is_owned flags and looks at the values in fields.
150          * Two objects with NULL inner values will be considered "equal" here.
151          */
152         public bool eq(org.ldk.structs.ChannelAnnouncement b) {
153                 bool ret = bindings.ChannelAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
154                 GC.KeepAlive(this);
155                 GC.KeepAlive(b);
156                 if (this != null) { this.ptrs_to.AddLast(b); };
157                 return ret;
158         }
159
160         public override bool Equals(object o) {
161                 if (!(o is ChannelAnnouncement)) return false;
162                 return this.eq((ChannelAnnouncement)o);
163         }
164         /**
165          * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
166          */
167         public byte[] write() {
168                 byte[] ret = bindings.ChannelAnnouncement_write(this.ptr);
169                 GC.KeepAlive(this);
170                 return ret;
171         }
172
173         /**
174          * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
175          */
176         public static Result_ChannelAnnouncementDecodeErrorZ read(byte[] ser) {
177                 long ret = bindings.ChannelAnnouncement_read(ser);
178                 GC.KeepAlive(ser);
179                 if (ret >= 0 && ret <= 4096) { return null; }
180                 Result_ChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_ChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
181                 return ret_hu_conv;
182         }
183
184 }
185 } } }