df6fb25e8d4b73f3aa2e49700d83ab499ed6dc81
[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                 byte[] ret = bindings.FundingSigned_get_channel_id(this.ptr);
27                 GC.KeepAlive(this);
28                 return ret;
29         }
30
31         /**
32          * The channel ID
33          */
34         public void set_channel_id(byte[] val) {
35                 bindings.FundingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * The signature of the channel acceptor (fundee) on the initial commitment transaction
42          */
43         public byte[] get_signature() {
44                 byte[] ret = bindings.FundingSigned_get_signature(this.ptr);
45                 GC.KeepAlive(this);
46                 return ret;
47         }
48
49         /**
50          * The signature of the channel acceptor (fundee) on the initial commitment transaction
51          */
52         public void set_signature(byte[] val) {
53                 bindings.FundingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         /**
59          * Constructs a new FundingSigned given each field
60          */
61         public static FundingSigned of(byte[] channel_id_arg, byte[] signature_arg) {
62                 long ret = bindings.FundingSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(signature_arg, 64));
63                 GC.KeepAlive(channel_id_arg);
64                 GC.KeepAlive(signature_arg);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
68                 return ret_hu_conv;
69         }
70
71         internal long clone_ptr() {
72                 long ret = bindings.FundingSigned_clone_ptr(this.ptr);
73                 GC.KeepAlive(this);
74                 return ret;
75         }
76
77         /**
78          * Creates a copy of the FundingSigned
79          */
80         public FundingSigned clone() {
81                 long ret = bindings.FundingSigned_clone(this.ptr);
82                 GC.KeepAlive(this);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Checks if two FundingSigneds contain equal inner contents.
91          * This ignores pointers and is_owned flags and looks at the values in fields.
92          * Two objects with NULL inner values will be considered "equal" here.
93          */
94         public bool eq(org.ldk.structs.FundingSigned b) {
95                 bool ret = bindings.FundingSigned_eq(this.ptr, b == null ? 0 : b.ptr);
96                 GC.KeepAlive(this);
97                 GC.KeepAlive(b);
98                 if (this != null) { this.ptrs_to.AddLast(b); };
99                 return ret;
100         }
101
102         public override bool Equals(object o) {
103                 if (!(o is FundingSigned)) return false;
104                 return this.eq((FundingSigned)o);
105         }
106         /**
107          * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
108          */
109         public byte[] write() {
110                 byte[] ret = bindings.FundingSigned_write(this.ptr);
111                 GC.KeepAlive(this);
112                 return ret;
113         }
114
115         /**
116          * Read a FundingSigned from a byte array, created by FundingSigned_write
117          */
118         public static Result_FundingSignedDecodeErrorZ read(byte[] ser) {
119                 long ret = bindings.FundingSigned_read(ser);
120                 GC.KeepAlive(ser);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);
123                 return ret_hu_conv;
124         }
125
126 }
127 } } }