e10f01ff17842bc9e7f6bc0602e95e51c3cd5e7a
[ldk-java] / c_sharp / src / org / ldk / structs / FundingSigned.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_signed`] message to be sent to or received from a peer.
11  * 
12  * Used in V1 channel establishment
13  * 
14  * [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
15  */
16 public class FundingSigned : CommonBase {
17         internal FundingSigned(object _dummy, long ptr) : base(ptr) { }
18         ~FundingSigned() {
19                 if (ptr != 0) { bindings.FundingSigned_free(ptr); }
20         }
21
22         /**
23          * The channel ID
24          */
25         public byte[] get_channel_id() {
26                 long ret = bindings.FundingSigned_get_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          * The channel ID
35          */
36         public void set_channel_id(byte[] val) {
37                 bindings.FundingSigned_set_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 signature of the channel acceptor (fundee) on the initial commitment transaction
44          */
45         public byte[] get_signature() {
46                 long ret = bindings.FundingSigned_get_signature(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 signature of the channel acceptor (fundee) on the initial commitment transaction
55          */
56         public void set_signature(byte[] val) {
57                 bindings.FundingSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * Constructs a new FundingSigned given each field
64          */
65         public static FundingSigned of(byte[] channel_id_arg, byte[] signature_arg) {
66                 long ret = bindings.FundingSigned_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)));
67                 GC.KeepAlive(channel_id_arg);
68                 GC.KeepAlive(signature_arg);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
71                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
72                 return ret_hu_conv;
73         }
74
75         internal long clone_ptr() {
76                 long ret = bindings.FundingSigned_clone_ptr(this.ptr);
77                 GC.KeepAlive(this);
78                 return ret;
79         }
80
81         /**
82          * Creates a copy of the FundingSigned
83          */
84         public FundingSigned clone() {
85                 long ret = bindings.FundingSigned_clone(this.ptr);
86                 GC.KeepAlive(this);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
89                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
90                 return ret_hu_conv;
91         }
92
93         /**
94          * Checks if two FundingSigneds contain equal inner contents.
95          * This ignores pointers and is_owned flags and looks at the values in fields.
96          * Two objects with NULL inner values will be considered "equal" here.
97          */
98         public bool eq(org.ldk.structs.FundingSigned b) {
99                 bool ret = bindings.FundingSigned_eq(this.ptr, b == null ? 0 : b.ptr);
100                 GC.KeepAlive(this);
101                 GC.KeepAlive(b);
102                 if (this != null) { this.ptrs_to.AddLast(b); };
103                 return ret;
104         }
105
106         public override bool Equals(object o) {
107                 if (!(o is FundingSigned)) return false;
108                 return this.eq((FundingSigned)o);
109         }
110         /**
111          * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
112          */
113         public byte[] write() {
114                 long ret = bindings.FundingSigned_write(this.ptr);
115                 GC.KeepAlive(this);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
118                 return ret_conv;
119         }
120
121         /**
122          * Read a FundingSigned from a byte array, created by FundingSigned_write
123          */
124         public static Result_FundingSignedDecodeErrorZ read(byte[] ser) {
125                 long ret = bindings.FundingSigned_read(InternalUtils.encodeUint8Array(ser));
126                 GC.KeepAlive(ser);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);
129                 return ret_hu_conv;
130         }
131
132 }
133 } } }