Merge pull request #123 from tnull/patch-1
[ldk-java] / src / main / java / org / ldk / structs / BaseSign.java
index cb82de4ef9323d2df71911cf3f73baa976b41896..9deff4d35421a78c5e929dbae26e0837370dfa6b 100644 (file)
@@ -181,6 +181,11 @@ public class BaseSign extends CommonBase {
                 * chosen to forgo their output as dust.
                 */
                Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx);
+               /**
+                * Computes the signature for a commitment transaction's anchor output used as an
+                * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
+                */
+               Result_SignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input);
                /**
                 * Signs a channel announcement message with our funding key and our node secret key (aka
                 * node_id or network_key), proving it comes from one of the channel participants.
@@ -283,6 +288,12 @@ public class BaseSign extends CommonBase {
                                long result = ret == null ? 0 : ret.clone_ptr();
                                return result;
                        }
+                       @Override public long sign_holder_anchor_input(byte[] anchor_tx, long input) {
+                               Result_SignatureNoneZ ret = arg.sign_holder_anchor_input(anchor_tx, input);
+                               Reference.reachabilityFence(arg);
+                               long result = ret == null ? 0 : ret.clone_ptr();
+                               return result;
+                       }
                        @Override public long sign_channel_announcement(long msg) {
                                org.ldk.structs.UnsignedChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, msg); }
                                Result_C2Tuple_SignatureSignatureZNoneZ ret = arg.sign_channel_announcement(msg_hu_conv);
@@ -349,7 +360,7 @@ public class BaseSign extends CommonBase {
                Reference.reachabilityFence(preimages);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
-               this.ptrs_to.add(holder_tx);
+               if (this != null) { this.ptrs_to.add(holder_tx); };
                return ret_hu_conv;
        }
 
@@ -386,7 +397,7 @@ public class BaseSign extends CommonBase {
                Reference.reachabilityFence(preimages);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
-               this.ptrs_to.add(commitment_tx);
+               if (this != null) { this.ptrs_to.add(commitment_tx); };
                return ret_hu_conv;
        }
 
@@ -425,7 +436,7 @@ public class BaseSign extends CommonBase {
                Reference.reachabilityFence(commitment_tx);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
-               this.ptrs_to.add(commitment_tx);
+               if (this != null) { this.ptrs_to.add(commitment_tx); };
                return ret_hu_conv;
        }
 
@@ -486,7 +497,7 @@ public class BaseSign extends CommonBase {
                Reference.reachabilityFence(htlc);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
-               this.ptrs_to.add(htlc);
+               if (this != null) { this.ptrs_to.add(htlc); };
                return ret_hu_conv;
        }
 
@@ -519,7 +530,7 @@ public class BaseSign extends CommonBase {
                Reference.reachabilityFence(htlc);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
-               this.ptrs_to.add(htlc);
+               if (this != null) { this.ptrs_to.add(htlc); };
                return ret_hu_conv;
        }
 
@@ -535,7 +546,21 @@ public class BaseSign extends CommonBase {
                Reference.reachabilityFence(closing_tx);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
-               this.ptrs_to.add(closing_tx);
+               if (this != null) { this.ptrs_to.add(closing_tx); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Computes the signature for a commitment transaction's anchor output used as an
+        * input within `anchor_tx`, which spends the commitment transaction, at index `input`.
+        */
+       public Result_SignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
+               long ret = bindings.BaseSign_sign_holder_anchor_input(this.ptr, anchor_tx, input);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(anchor_tx);
+               Reference.reachabilityFence(input);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
 
@@ -556,7 +581,7 @@ public class BaseSign extends CommonBase {
                Reference.reachabilityFence(msg);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_C2Tuple_SignatureSignatureZNoneZ ret_hu_conv = Result_C2Tuple_SignatureSignatureZNoneZ.constr_from_ptr(ret);
-               this.ptrs_to.add(msg);
+               if (this != null) { this.ptrs_to.add(msg); };
                return ret_hu_conv;
        }
 
@@ -576,7 +601,7 @@ public class BaseSign extends CommonBase {
                bindings.BaseSign_ready_channel(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr);
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(channel_parameters);
-               this.ptrs_to.add(channel_parameters);
+               if (this != null) { this.ptrs_to.add(channel_parameters); };
        }
 
        /**
@@ -588,7 +613,7 @@ public class BaseSign extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }