1166194df6809a267e8cc08edeab4d1f106cb9b9
[ldk-java] / c_sharp / src / org / ldk / structs / FundingCreated.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 [`funding_created`] message to be sent to or received from a peer.
11  * 
12  * Used in V1 channel establishment
13  * 
14  * [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
15  */
16 public class FundingCreated : CommonBase {
17         internal FundingCreated(object _dummy, long ptr) : base(ptr) { }
18         ~FundingCreated() {
19                 if (ptr != 0) { bindings.FundingCreated_free(ptr); }
20         }
21
22         /**
23          * A temporary channel ID, until the funding is established
24          */
25         public byte[] get_temporary_channel_id() {
26                 long ret = bindings.FundingCreated_get_temporary_channel_id(this.ptr);
27                 GC.KeepAlive(this);
28                 if (ret >= 0 && ret <= 4096) { return null; }
29                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
30                 return ret_conv;
31         }
32
33         /**
34          * A temporary channel ID, until the funding is established
35          */
36         public void set_temporary_channel_id(byte[] val) {
37                 bindings.FundingCreated_set_temporary_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
38                 GC.KeepAlive(this);
39                 GC.KeepAlive(val);
40         }
41
42         /**
43          * The funding transaction ID
44          */
45         public byte[] get_funding_txid() {
46                 long ret = bindings.FundingCreated_get_funding_txid(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
50                 return ret_conv;
51         }
52
53         /**
54          * The funding transaction ID
55          */
56         public void set_funding_txid(byte[] val) {
57                 bindings.FundingCreated_set_funding_txid(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * The specific output index funding this channel
64          */
65         public short get_funding_output_index() {
66                 short ret = bindings.FundingCreated_get_funding_output_index(this.ptr);
67                 GC.KeepAlive(this);
68                 return ret;
69         }
70
71         /**
72          * The specific output index funding this channel
73          */
74         public void set_funding_output_index(short val) {
75                 bindings.FundingCreated_set_funding_output_index(this.ptr, val);
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(val);
78         }
79
80         /**
81          * The signature of the channel initiator (funder) on the initial commitment transaction
82          */
83         public byte[] get_signature() {
84                 long ret = bindings.FundingCreated_get_signature(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 signature of the channel initiator (funder) on the initial commitment transaction
93          */
94         public void set_signature(byte[] val) {
95                 bindings.FundingCreated_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
96                 GC.KeepAlive(this);
97                 GC.KeepAlive(val);
98         }
99
100         /**
101          * Constructs a new FundingCreated given each field
102          */
103         public static FundingCreated of(byte[] temporary_channel_id_arg, byte[] funding_txid_arg, short funding_output_index_arg, byte[] signature_arg) {
104                 long ret = bindings.FundingCreated_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(temporary_channel_id_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_txid_arg, 32)), funding_output_index_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)));
105                 GC.KeepAlive(temporary_channel_id_arg);
106                 GC.KeepAlive(funding_txid_arg);
107                 GC.KeepAlive(funding_output_index_arg);
108                 GC.KeepAlive(signature_arg);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 org.ldk.structs.FundingCreated ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingCreated(null, ret); }
111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
112                 return ret_hu_conv;
113         }
114
115         internal long clone_ptr() {
116                 long ret = bindings.FundingCreated_clone_ptr(this.ptr);
117                 GC.KeepAlive(this);
118                 return ret;
119         }
120
121         /**
122          * Creates a copy of the FundingCreated
123          */
124         public FundingCreated clone() {
125                 long ret = bindings.FundingCreated_clone(this.ptr);
126                 GC.KeepAlive(this);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 org.ldk.structs.FundingCreated ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingCreated(null, ret); }
129                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
130                 return ret_hu_conv;
131         }
132
133         /**
134          * Checks if two FundingCreateds contain equal inner contents.
135          * This ignores pointers and is_owned flags and looks at the values in fields.
136          * Two objects with NULL inner values will be considered "equal" here.
137          */
138         public bool eq(org.ldk.structs.FundingCreated b) {
139                 bool ret = bindings.FundingCreated_eq(this.ptr, b == null ? 0 : b.ptr);
140                 GC.KeepAlive(this);
141                 GC.KeepAlive(b);
142                 if (this != null) { this.ptrs_to.AddLast(b); };
143                 return ret;
144         }
145
146         public override bool Equals(object o) {
147                 if (!(o is FundingCreated)) return false;
148                 return this.eq((FundingCreated)o);
149         }
150         /**
151          * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
152          */
153         public byte[] write() {
154                 long ret = bindings.FundingCreated_write(this.ptr);
155                 GC.KeepAlive(this);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
158                 return ret_conv;
159         }
160
161         /**
162          * Read a FundingCreated from a byte array, created by FundingCreated_write
163          */
164         public static Result_FundingCreatedDecodeErrorZ read(byte[] ser) {
165                 long ret = bindings.FundingCreated_read(InternalUtils.encodeUint8Array(ser));
166                 GC.KeepAlive(ser);
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 Result_FundingCreatedDecodeErrorZ ret_hu_conv = Result_FundingCreatedDecodeErrorZ.constr_from_ptr(ret);
169                 return ret_hu_conv;
170         }
171
172 }
173 } } }