Generate Events from ChannelMonitor to indicate spendable ouputs
[rust-lightning] / src / chain / keysinterface.rs
1 //! keysinterface provides keys into rust-lightning and defines some useful enums which describe
2 //! spendable on-chain outputs which the user owns and is responsible for using just as any other
3 //! on-chain output which is theirs.
4
5 use bitcoin::blockdata::transaction::{OutPoint, TxOut};
6 use bitcoin::blockdata::script::Script;
7
8 use secp256k1::key::SecretKey;
9
10 /// When on-chain outputs are created by rust-lightning an event is generated which informs the
11 /// user thereof. This enum describes the format of the output and provides the OutPoint.
12 pub enum SpendableOutputDescriptor {
13         /// Outpoint with an output to a script which was provided via KeysInterface, thus you should
14         /// have stored somewhere how to spend script_pubkey!
15         /// Outputs from a justice tx, claim tx or preimage tx
16         StaticOutput {
17                 /// The outpoint spendable by user wallet
18                 outpoint: OutPoint,
19                 /// The output which is referenced by the given outpoint
20                 output: TxOut,
21         },
22         /// Outpoint commits to a P2WSH, should be spend by the following witness :
23         /// <local_delayedsig> 0 <witnessScript>
24         /// With input nSequence set to_self_delay.
25         /// Outputs from a HTLC-Success/Timeout tx
26         DynamicOutput {
27                 /// Outpoint spendable by user wallet
28                 outpoint: OutPoint,
29                 /// local_delayedkey = delayed_payment_basepoint_secret + SHA256(per_commitment_point || delayed_payment_basepoint
30                 local_delayedkey: SecretKey,
31                 /// witness redeemScript encumbering output
32                 witness_script: Script,
33                 /// nSequence input must commit to self_delay to satisfy script's OP_CSV
34                 to_self_delay: u16,
35         }
36 }