X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FBaseSign.java;h=9deff4d35421a78c5e929dbae26e0837370dfa6b;hb=5e9de82b3a7712a41189756d9d16d946142b2ac5;hp=7bc6174c52154b3e0a8dbefe3d9a0ef840f454a1;hpb=6fe917116a65d7b62123226c4240d77ea2719783;p=ldk-java diff --git a/src/main/java/org/ldk/structs/BaseSign.java b/src/main/java/org/ldk/structs/BaseSign.java index 7bc6174c..9deff4d3 100644 --- a/src/main/java/org/ldk/structs/BaseSign.java +++ b/src/main/java/org/ldk/structs/BaseSign.java @@ -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. @@ -224,7 +229,7 @@ public class BaseSign extends CommonBase { return result; } @Override public long validate_holder_commitment(long holder_tx, byte[][] preimages) { - HolderCommitmentTransaction holder_tx_hu_conv = null; if (holder_tx < 0 || holder_tx > 4096) { holder_tx_hu_conv = new HolderCommitmentTransaction(null, holder_tx); } + org.ldk.structs.HolderCommitmentTransaction holder_tx_hu_conv = null; if (holder_tx < 0 || holder_tx > 4096) { holder_tx_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, holder_tx); } Result_NoneNoneZ ret = arg.validate_holder_commitment(holder_tx_hu_conv, preimages); Reference.reachabilityFence(arg); long result = ret == null ? 0 : ret.clone_ptr(); @@ -237,7 +242,7 @@ public class BaseSign extends CommonBase { return result; } @Override public long sign_counterparty_commitment(long commitment_tx, byte[][] preimages) { - CommitmentTransaction commitment_tx_hu_conv = null; if (commitment_tx < 0 || commitment_tx > 4096) { commitment_tx_hu_conv = new CommitmentTransaction(null, commitment_tx); } + org.ldk.structs.CommitmentTransaction commitment_tx_hu_conv = null; if (commitment_tx < 0 || commitment_tx > 4096) { commitment_tx_hu_conv = new org.ldk.structs.CommitmentTransaction(null, commitment_tx); } Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv, preimages); Reference.reachabilityFence(arg); long result = ret == null ? 0 : ret.clone_ptr(); @@ -250,7 +255,7 @@ public class BaseSign extends CommonBase { return result; } @Override public long sign_holder_commitment_and_htlcs(long commitment_tx) { - HolderCommitmentTransaction commitment_tx_hu_conv = null; if (commitment_tx < 0 || commitment_tx > 4096) { commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx); } + org.ldk.structs.HolderCommitmentTransaction commitment_tx_hu_conv = null; if (commitment_tx < 0 || commitment_tx > 4096) { commitment_tx_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, commitment_tx); } Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(commitment_tx_hu_conv); Reference.reachabilityFence(arg); long result = ret == null ? 0 : ret.clone_ptr(); @@ -263,35 +268,41 @@ public class BaseSign extends CommonBase { return result; } @Override public long sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc) { - HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); } + org.ldk.structs.HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, htlc); } Result_SignatureNoneZ ret = arg.sign_justice_revoked_htlc(justice_tx, input, amount, per_commitment_key, htlc_hu_conv); Reference.reachabilityFence(arg); long result = ret == null ? 0 : ret.clone_ptr(); return result; } @Override public long sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc) { - HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); } + org.ldk.structs.HTLCOutputInCommitment htlc_hu_conv = null; if (htlc < 0 || htlc > 4096) { htlc_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, htlc); } Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc_hu_conv); Reference.reachabilityFence(arg); long result = ret == null ? 0 : ret.clone_ptr(); return result; } @Override public long sign_closing_transaction(long closing_tx) { - ClosingTransaction closing_tx_hu_conv = null; if (closing_tx < 0 || closing_tx > 4096) { closing_tx_hu_conv = new ClosingTransaction(null, closing_tx); } + org.ldk.structs.ClosingTransaction closing_tx_hu_conv = null; if (closing_tx < 0 || closing_tx > 4096) { closing_tx_hu_conv = new org.ldk.structs.ClosingTransaction(null, closing_tx); } Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx_hu_conv); Reference.reachabilityFence(arg); 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) { - UnsignedChannelAnnouncement msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new UnsignedChannelAnnouncement(null, 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); Reference.reachabilityFence(arg); long result = ret == null ? 0 : ret.clone_ptr(); return result; } @Override public void ready_channel(long channel_parameters) { - ChannelTransactionParameters channel_parameters_hu_conv = null; if (channel_parameters < 0 || channel_parameters > 4096) { channel_parameters_hu_conv = new ChannelTransactionParameters(null, channel_parameters); } + org.ldk.structs.ChannelTransactionParameters channel_parameters_hu_conv = null; if (channel_parameters < 0 || channel_parameters > 4096) { channel_parameters_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, channel_parameters); } arg.ready_channel(channel_parameters_hu_conv); Reference.reachabilityFence(arg); } @@ -343,13 +354,13 @@ public class BaseSign extends CommonBase { * irrelevant or duplicate preimages. */ public Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx, byte[][] preimages) { - long ret = bindings.BaseSign_validate_holder_commitment(this.ptr, holder_tx == null ? 0 : holder_tx.ptr & ~1, preimages != null ? Arrays.stream(preimages).map(preimages_conv_8 -> InternalUtils.check_arr_len(preimages_conv_8, 32)).toArray(byte[][]::new) : null); + long ret = bindings.BaseSign_validate_holder_commitment(this.ptr, holder_tx == null ? 0 : holder_tx.ptr, preimages != null ? Arrays.stream(preimages).map(preimages_conv_8 -> InternalUtils.check_arr_len(preimages_conv_8, 32)).toArray(byte[][]::new) : null); Reference.reachabilityFence(this); Reference.reachabilityFence(holder_tx); 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; } @@ -380,13 +391,13 @@ public class BaseSign extends CommonBase { * irrelevant or duplicate preimages. */ public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages) { - long ret = bindings.BaseSign_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1, preimages != null ? Arrays.stream(preimages).map(preimages_conv_8 -> InternalUtils.check_arr_len(preimages_conv_8, 32)).toArray(byte[][]::new) : null); + long ret = bindings.BaseSign_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr, preimages != null ? Arrays.stream(preimages).map(preimages_conv_8 -> InternalUtils.check_arr_len(preimages_conv_8, 32)).toArray(byte[][]::new) : null); Reference.reachabilityFence(this); Reference.reachabilityFence(commitment_tx); 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; } @@ -420,12 +431,12 @@ public class BaseSign extends CommonBase { * May return Err if key derivation fails. Callers, such as ChannelMonitor, will panic in such a case. */ public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx) { - long ret = bindings.BaseSign_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1); + long ret = bindings.BaseSign_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr); Reference.reachabilityFence(this); 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; } @@ -477,7 +488,7 @@ public class BaseSign extends CommonBase { * (which is committed to in the BIP 143 signatures). */ public Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc) { - long ret = bindings.BaseSign_sign_justice_revoked_htlc(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32), htlc == null ? 0 : htlc.ptr & ~1); + long ret = bindings.BaseSign_sign_justice_revoked_htlc(this.ptr, justice_tx, input, amount, InternalUtils.check_arr_len(per_commitment_key, 32), htlc == null ? 0 : htlc.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(justice_tx); Reference.reachabilityFence(input); @@ -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; } @@ -510,7 +521,7 @@ public class BaseSign extends CommonBase { * BIP 143 signature. */ public Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc) { - long ret = bindings.BaseSign_sign_counterparty_htlc_transaction(this.ptr, htlc_tx, input, amount, InternalUtils.check_arr_len(per_commitment_point, 33), htlc == null ? 0 : htlc.ptr & ~1); + long ret = bindings.BaseSign_sign_counterparty_htlc_transaction(this.ptr, htlc_tx, input, amount, InternalUtils.check_arr_len(per_commitment_point, 33), htlc == null ? 0 : htlc.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(htlc_tx); Reference.reachabilityFence(input); @@ -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; } @@ -530,12 +541,26 @@ public class BaseSign extends CommonBase { * chosen to forgo their output as dust. */ public Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx) { - long ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr & ~1); + long ret = bindings.BaseSign_sign_closing_transaction(this.ptr, closing_tx == null ? 0 : closing_tx.ptr); Reference.reachabilityFence(this); 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; } @@ -551,12 +576,12 @@ public class BaseSign extends CommonBase { * protocol. */ public Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg) { - long ret = bindings.BaseSign_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1); + long ret = bindings.BaseSign_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr); Reference.reachabilityFence(this); 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; } @@ -573,10 +598,10 @@ public class BaseSign extends CommonBase { * Will be called before any signatures are applied. */ public void ready_channel(ChannelTransactionParameters channel_parameters) { - bindings.BaseSign_ready_channel(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr & ~1); + 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); }; } /** @@ -587,8 +612,8 @@ public class BaseSign extends CommonBase { long ret = bindings.BaseSign_get_pubkeys(this.ptr); Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); } - ret_hu_conv.ptrs_to.add(this); + org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; }