Merge pull request #124 from TheBlueMatt/main
[ldk-java] / c_sharp / src / org / ldk / structs / TrustedClosingTransaction.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 wrapper on ClosingTransaction indicating that the built bitcoin
11  * transaction is trusted.
12  * 
13  * See trust() and verify() functions on CommitmentTransaction.
14  * 
15  * This structure implements Deref.
16  */
17 public class TrustedClosingTransaction : CommonBase {
18         internal TrustedClosingTransaction(object _dummy, long ptr) : base(ptr) { }
19         ~TrustedClosingTransaction() {
20                 if (ptr != 0) { bindings.TrustedClosingTransaction_free(ptr); }
21         }
22
23         /**
24          * The pre-built Bitcoin commitment transaction
25          */
26         public byte[] built_transaction() {
27                 byte[] ret = bindings.TrustedClosingTransaction_built_transaction(this.ptr);
28                 GC.KeepAlive(this);
29                 return ret;
30         }
31
32         /**
33          * Get the SIGHASH_ALL sighash value of the transaction.
34          * 
35          * This can be used to verify a signature.
36          */
37         public byte[] get_sighash_all(byte[] funding_redeemscript, long channel_value_satoshis) {
38                 byte[] ret = bindings.TrustedClosingTransaction_get_sighash_all(this.ptr, funding_redeemscript, channel_value_satoshis);
39                 GC.KeepAlive(this);
40                 GC.KeepAlive(funding_redeemscript);
41                 GC.KeepAlive(channel_value_satoshis);
42                 return ret;
43         }
44
45         /**
46          * Sign a transaction, either because we are counter-signing the counterparty's transaction or
47          * because we are about to broadcast a holder transaction.
48          */
49         public byte[] sign(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis) {
50                 byte[] ret = bindings.TrustedClosingTransaction_sign(this.ptr, InternalUtils.check_arr_len(funding_key, 32), funding_redeemscript, channel_value_satoshis);
51                 GC.KeepAlive(this);
52                 GC.KeepAlive(funding_key);
53                 GC.KeepAlive(funding_redeemscript);
54                 GC.KeepAlive(channel_value_satoshis);
55                 return ret;
56         }
57
58 }
59 } } }