Merge pull request #46 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / ChannelAnnouncement.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * A channel_announcement message to be sent or received from a peer
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ChannelAnnouncement extends CommonBase {
15         ChannelAnnouncement(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.ChannelAnnouncement_free(ptr); }
20         }
21
22         /**
23          * Authentication of the announcement by the first public node
24          */
25         public byte[] get_node_signature_1() {
26                 byte[] ret = bindings.ChannelAnnouncement_get_node_signature_1(this.ptr);
27                 return ret;
28         }
29
30         /**
31          * Authentication of the announcement by the first public node
32          */
33         public void set_node_signature_1(byte[] val) {
34                 bindings.ChannelAnnouncement_set_node_signature_1(this.ptr, val);
35         }
36
37         /**
38          * Authentication of the announcement by the second public node
39          */
40         public byte[] get_node_signature_2() {
41                 byte[] ret = bindings.ChannelAnnouncement_get_node_signature_2(this.ptr);
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, val);
50         }
51
52         /**
53          * Proof of funding UTXO ownership by the first public node
54          */
55         public byte[] get_bitcoin_signature_1() {
56                 byte[] ret = bindings.ChannelAnnouncement_get_bitcoin_signature_1(this.ptr);
57                 return ret;
58         }
59
60         /**
61          * Proof of funding UTXO ownership by the first public node
62          */
63         public void set_bitcoin_signature_1(byte[] val) {
64                 bindings.ChannelAnnouncement_set_bitcoin_signature_1(this.ptr, val);
65         }
66
67         /**
68          * Proof of funding UTXO ownership by the second public node
69          */
70         public byte[] get_bitcoin_signature_2() {
71                 byte[] ret = bindings.ChannelAnnouncement_get_bitcoin_signature_2(this.ptr);
72                 return ret;
73         }
74
75         /**
76          * Proof of funding UTXO ownership by the second public node
77          */
78         public void set_bitcoin_signature_2(byte[] val) {
79                 bindings.ChannelAnnouncement_set_bitcoin_signature_2(this.ptr, val);
80         }
81
82         /**
83          * The actual announcement
84          */
85         public UnsignedChannelAnnouncement get_contents() {
86                 long ret = bindings.ChannelAnnouncement_get_contents(this.ptr);
87                 if (ret < 1024) { return null; }
88                 UnsignedChannelAnnouncement ret_hu_conv = new UnsignedChannelAnnouncement(null, ret);
89                 ret_hu_conv.ptrs_to.add(this);
90                 return ret_hu_conv;
91         }
92
93         /**
94          * The actual announcement
95          */
96         public void set_contents(UnsignedChannelAnnouncement val) {
97                 bindings.ChannelAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr & ~1);
98                 this.ptrs_to.add(val);
99         }
100
101         /**
102          * Constructs a new ChannelAnnouncement given each field
103          */
104         public static ChannelAnnouncement of(byte[] node_signature_1_arg, byte[] node_signature_2_arg, byte[] bitcoin_signature_1_arg, byte[] bitcoin_signature_2_arg, UnsignedChannelAnnouncement contents_arg) {
105                 long ret = bindings.ChannelAnnouncement_new(node_signature_1_arg, node_signature_2_arg, bitcoin_signature_1_arg, bitcoin_signature_2_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1);
106                 if (ret < 1024) { return null; }
107                 ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret);
108                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
109                 ret_hu_conv.ptrs_to.add(contents_arg);
110                 return ret_hu_conv;
111         }
112
113         /**
114          * Creates a copy of the ChannelAnnouncement
115          */
116         public ChannelAnnouncement clone() {
117                 long ret = bindings.ChannelAnnouncement_clone(this.ptr);
118                 if (ret < 1024) { return null; }
119                 ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret);
120                 ret_hu_conv.ptrs_to.add(this);
121                 return ret_hu_conv;
122         }
123
124         /**
125          * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
126          */
127         public byte[] write() {
128                 byte[] ret = bindings.ChannelAnnouncement_write(this.ptr);
129                 return ret;
130         }
131
132         /**
133          * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
134          */
135         public static Result_ChannelAnnouncementDecodeErrorZ read(byte[] ser) {
136                 long ret = bindings.ChannelAnnouncement_read(ser);
137                 if (ret < 1024) { return null; }
138                 Result_ChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_ChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
139                 return ret_hu_conv;
140         }
141
142 }