[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / SignBolt12InvoiceFn.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of SignBolt12InvoiceFn */
12 public interface SignBolt12InvoiceFnInterface {
13         /**Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
14          */
15         Result_SchnorrSignatureNoneZ sign_invoice(UnsignedBolt12Invoice message);
16 }
17
18 /**
19  * A function for signing an [`UnsignedBolt12Invoice`].
20  */
21 public class SignBolt12InvoiceFn : CommonBase {
22         internal bindings.LDKSignBolt12InvoiceFn bindings_instance;
23         internal long instance_idx;
24
25         internal SignBolt12InvoiceFn(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
26         ~SignBolt12InvoiceFn() {
27                 if (ptr != 0) { bindings.SignBolt12InvoiceFn_free(ptr); }
28         }
29
30         private class LDKSignBolt12InvoiceFnHolder { internal SignBolt12InvoiceFn held; }
31         private class LDKSignBolt12InvoiceFnImpl : bindings.LDKSignBolt12InvoiceFn {
32                 internal LDKSignBolt12InvoiceFnImpl(SignBolt12InvoiceFnInterface arg, LDKSignBolt12InvoiceFnHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
33                 private SignBolt12InvoiceFnInterface arg;
34                 private LDKSignBolt12InvoiceFnHolder impl_holder;
35                 public long sign_invoice(long _message) {
36                         org.ldk.structs.UnsignedBolt12Invoice _message_hu_conv = null; if (_message < 0 || _message > 4096) { _message_hu_conv = new org.ldk.structs.UnsignedBolt12Invoice(null, _message); }
37                         Result_SchnorrSignatureNoneZ ret = arg.sign_invoice(_message_hu_conv);
38                                 GC.KeepAlive(arg);
39                         long result = ret.clone_ptr();
40                         return result;
41                 }
42         }
43
44         /** Creates a new instance of SignBolt12InvoiceFn from a given implementation */
45         public static SignBolt12InvoiceFn new_impl(SignBolt12InvoiceFnInterface arg) {
46                 LDKSignBolt12InvoiceFnHolder impl_holder = new LDKSignBolt12InvoiceFnHolder();
47                 LDKSignBolt12InvoiceFnImpl impl = new LDKSignBolt12InvoiceFnImpl(arg, impl_holder);
48                 long[] ptr_idx = bindings.LDKSignBolt12InvoiceFn_new(impl);
49
50                 impl_holder.held = new SignBolt12InvoiceFn(null, ptr_idx[0]);
51                 impl_holder.held.instance_idx = ptr_idx[1];
52                 impl_holder.held.bindings_instance = impl;
53                 return impl_holder.held;
54         }
55
56         /**
57          * Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
58          */
59         public Result_SchnorrSignatureNoneZ sign_invoice(org.ldk.structs.UnsignedBolt12Invoice message) {
60                 long ret = bindings.SignBolt12InvoiceFn_sign_invoice(this.ptr, message.ptr);
61                 GC.KeepAlive(this);
62                 GC.KeepAlive(message);
63                 if (ret >= 0 && ret <= 4096) { return null; }
64                 Result_SchnorrSignatureNoneZ ret_hu_conv = Result_SchnorrSignatureNoneZ.constr_from_ptr(ret);
65                 if (this != null) { this.ptrs_to.AddLast(message); };
66                 return ret_hu_conv;
67         }
68
69 }
70 } } }