Package org.ldk.structs
Class EcdsaChannelSigner
- java.lang.Object
-
- org.ldk.structs.EcdsaChannelSigner
-
public class EcdsaChannelSigner extends Object
A trait to sign Lightning channel transactions as described in [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md). Signing services could be implemented on a hardware wallet and should implement signing policies in order to be secure. Please refer to the [VLS Policy Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md) for an example of such policies.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
EcdsaChannelSigner.EcdsaChannelSignerInterface
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Destroys the object, freeing associated resources.protected void
finalize()
ChannelSigner
get_channel_signer()
Gets the underlying ChannelSigner.static EcdsaChannelSigner
new_impl(EcdsaChannelSigner.EcdsaChannelSignerInterface arg, ChannelSigner.ChannelSignerInterface ChannelSigner_impl, ChannelPublicKeys pubkeys)
Result_SignatureNoneZ
sign_channel_announcement_with_funding_key(UnsignedChannelAnnouncement msg)
Signs a channel announcement message with our funding key proving it comes from one of the channel participants.Result_SignatureNoneZ
sign_closing_transaction(ClosingTransaction closing_tx)
Create a signature for a (proposed) closing transaction.Result_C2Tuple_SignatureCVec_SignatureZZNoneZ
sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages)
Create a signature for a counterparty's commitment transaction and associated HTLC transactions.Result_SignatureNoneZ
sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc)
Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment transaction, either offered or received.Result_SignatureNoneZ
sign_holder_anchor_input(byte[] anchor_tx, long input)
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_C2Tuple_SignatureCVec_SignatureZZNoneZ
sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx)
Creates a signature for a holder's commitment transaction and its claiming HTLC transactions.Result_SignatureNoneZ
sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc)
Create a signature for the given input in a transaction spending a commitment transaction HTLC output when our counterparty broadcasts an old state.Result_SignatureNoneZ
sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key)
Create a signature for the given input in a transaction spending an HTLC transaction output or a commitment transaction `to_local` output when our counterparty broadcasts an old state.Result_NoneNoneZ
validate_counterparty_revocation(long idx, byte[] secret)
Validate the counterparty's revocation.
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
destroy
public void destroy()
Destroys the object, freeing associated resources. After this call, any access to this object may result in a SEGFAULT or worse. You should generally NEVER call this method. You should let the garbage collector do this for you when it finalizes objects. However, it may be useful for types which represent locks and should be closed immediately to avoid holding locks until the GC runs.
-
new_impl
public static EcdsaChannelSigner new_impl(EcdsaChannelSigner.EcdsaChannelSignerInterface arg, ChannelSigner.ChannelSignerInterface ChannelSigner_impl, ChannelPublicKeys pubkeys)
-
get_channel_signer
public ChannelSigner get_channel_signer()
Gets the underlying ChannelSigner.
-
sign_counterparty_commitment
public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages)
Create a signature for a counterparty's commitment transaction and associated HTLC transactions. Note that if signing fails or is rejected, the channel will be force-closed. Policy checks should be implemented in this function, including checking the amount sent to us and checking the HTLCs. The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. A validating signer should ensure that an HTLC output is removed only when the matching preimage is provided, or when the value to holder is restored. Note that all the relevant preimages will be provided, but there may also be additional irrelevant or duplicate preimages.
-
validate_counterparty_revocation
public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret)
Validate the counterparty's revocation. This is required in order for the signer to make sure that the state has moved forward and it is safe to sign the next counterparty commitment.
-
sign_holder_commitment_and_htlcs
public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx)
Creates a signature for a holder's commitment transaction and its claiming HTLC transactions. This will be called - with a non-revoked `commitment_tx`. - with the latest `commitment_tx` when we initiate a force-close. - with the previous `commitment_tx`, just to get claiming HTLC signatures, if we are reacting to a [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) that decided to broadcast before it had been updated to the latest `commitment_tx`. This may be called multiple times for the same transaction. An external signer implementation should check that the commitment has not been revoked. [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
-
sign_justice_revoked_output
public Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key)
Create a signature for the given input in a transaction spending an HTLC transaction output or a commitment transaction `to_local` output when our counterparty broadcasts an old state. A justice transaction may claim multiple outputs at the same time if timelocks are similar, but only a signature for the input at index `input` should be signed for here. It may be called multiple times for same output(s) if a fee-bump is needed with regards to an upcoming timelock expiration. Amount is value of the output spent by this input, committed to in the BIP 143 signature. `per_commitment_key` is revocation secret which was provided by our counterparty when they revoked the state which they eventually broadcast. It's not a _holder_ secret key and does not allow the spending of any funds by itself (you need our holder `revocation_secret` to do so).
-
sign_justice_revoked_htlc
public Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc)
Create a signature for the given input in a transaction spending a commitment transaction HTLC output when our counterparty broadcasts an old state. A justice transaction may claim multiple outputs at the same time if timelocks are similar, but only a signature for the input at index `input` should be signed for here. It may be called multiple times for same output(s) if a fee-bump is needed with regards to an upcoming timelock expiration. `amount` is the value of the output spent by this input, committed to in the BIP 143 signature. `per_commitment_key` is revocation secret which was provided by our counterparty when they revoked the state which they eventually broadcast. It's not a _holder_ secret key and does not allow the spending of any funds by itself (you need our holder revocation_secret to do so). `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script (which is committed to in the BIP 143 signatures).
-
sign_counterparty_htlc_transaction
public Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc)
Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment transaction, either offered or received. Such a transaction may claim multiples offered outputs at same time if we know the preimage for each when we create it, but only the input at index `input` should be signed for here. It may be called multiple times for same output(s) if a fee-bump is needed with regards to an upcoming timelock expiration. `witness_script` is either an offered or received script as defined in BOLT3 for HTLC outputs. `amount` is value of the output spent by this input, committed to in the BIP 143 signature. `per_commitment_point` is the dynamic point corresponding to the channel state detected onchain. It has been generated by our counterparty and is used to derive channel state keys, which are then included in the witness script and committed to in the BIP 143 signature.
-
sign_closing_transaction
public Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx)
Create a signature for a (proposed) closing transaction. Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have chosen to forgo their output as dust.
-
sign_holder_anchor_input
public Result_SignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input)
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`.
-
sign_channel_announcement_with_funding_key
public Result_SignatureNoneZ sign_channel_announcement_with_funding_key(UnsignedChannelAnnouncement msg)
Signs a channel announcement message with our funding key proving it comes from one of the channel participants. Channel announcements also require a signature from each node's network key. Our node signature is computed through [`NodeSigner::sign_gossip_message`]. Note that if this fails or is rejected, the channel will not be publicly announced and our counterparty may (though likely will not) close the channel on us for violating the protocol.
-
-