@@ -42,9 +42,9 @@ use std::io::Error;
42
42
use ln:: msgs:: { DecodeError , MAX_VALUE_MSAT } ;
43
43
44
44
/// Information about a spendable output to a P2WSH script. See
45
- /// SpendableOutputDescriptor::DynamicOutputP2WSH for more details on how to spend this.
45
+ /// SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
46
46
#[ derive( Clone , Debug , PartialEq ) ]
47
- pub struct DynamicP2WSHOutputDescriptor {
47
+ pub struct DelayedPaymentOutputDescriptor {
48
48
/// The outpoint which is spendable
49
49
pub outpoint : OutPoint ,
50
50
/// Per commitment point to derive delayed_payment_key by key holder
@@ -64,17 +64,17 @@ pub struct DynamicP2WSHOutputDescriptor {
64
64
/// The value of the channel which this output originated from, possibly indirectly.
65
65
pub channel_value_satoshis : u64 ,
66
66
}
67
- impl DynamicP2WSHOutputDescriptor {
67
+ impl DelayedPaymentOutputDescriptor {
68
68
/// The maximum length a well-formed witness spending one of these should have.
69
69
// Calculated as 1 byte length + 73 byte signature, 1 byte empty vec push, 1 byte length plus
70
70
// redeemscript push length.
71
71
pub const MAX_WITNESS_LENGTH : usize = 1 + 73 + 1 + chan_utils:: REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH + 1 ;
72
72
}
73
73
74
74
/// Information about a spendable output to our "payment key". See
75
- /// SpendableOutputDescriptor::StaticOutputCounterpartyPayment for more details on how to spend this.
75
+ /// SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this.
76
76
#[ derive( Clone , Debug , PartialEq ) ]
77
- pub struct StaticCounterpartyPaymentOutputDescriptor {
77
+ pub struct StaticPaymentOutputDescriptor {
78
78
/// The outpoint which is spendable
79
79
pub outpoint : OutPoint ,
80
80
/// The output which is referenced by the given outpoint
@@ -86,7 +86,7 @@ pub struct StaticCounterpartyPaymentOutputDescriptor {
86
86
/// The value of the channel which this transactions spends.
87
87
pub channel_value_satoshis : u64 ,
88
88
}
89
- impl StaticCounterpartyPaymentOutputDescriptor {
89
+ impl StaticPaymentOutputDescriptor {
90
90
/// The maximum length a well-formed witness spending one of these should have.
91
91
// Calculated as 1 byte legnth + 73 byte signature, 1 byte empty vec push, 1 byte length plus
92
92
// redeemscript push length.
@@ -139,15 +139,15 @@ pub enum SpendableOutputDescriptor {
139
139
/// regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey
140
140
/// (derived as above), and the to_self_delay contained here to
141
141
/// chan_utils::get_revokeable_redeemscript.
142
- DynamicOutputP2WSH ( DynamicP2WSHOutputDescriptor ) ,
142
+ DelayedPaymentOutput ( DelayedPaymentOutputDescriptor ) ,
143
143
/// An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
144
144
/// corresponds to the public key in ChannelKeys::pubkeys().payment_point).
145
145
/// The witness in the spending input, is, thus, simply:
146
146
/// <BIP 143 signature> <payment key>
147
147
///
148
148
/// These are generally the result of our counterparty having broadcast the current state,
149
149
/// allowing us to claim the non-HTLC-encumbered outputs immediately.
150
- StaticOutputCounterpartyPayment ( StaticCounterpartyPaymentOutputDescriptor ) ,
150
+ StaticPaymentOutput ( StaticPaymentOutputDescriptor ) ,
151
151
}
152
152
153
153
impl Writeable for SpendableOutputDescriptor {
@@ -158,7 +158,7 @@ impl Writeable for SpendableOutputDescriptor {
158
158
outpoint. write ( writer) ?;
159
159
output. write ( writer) ?;
160
160
} ,
161
- & SpendableOutputDescriptor :: DynamicOutputP2WSH ( ref descriptor) => {
161
+ & SpendableOutputDescriptor :: DelayedPaymentOutput ( ref descriptor) => {
162
162
1u8 . write ( writer) ?;
163
163
descriptor. outpoint . write ( writer) ?;
164
164
descriptor. per_commitment_point . write ( writer) ?;
@@ -168,7 +168,7 @@ impl Writeable for SpendableOutputDescriptor {
168
168
descriptor. channel_keys_id . write ( writer) ?;
169
169
descriptor. channel_value_satoshis . write ( writer) ?;
170
170
} ,
171
- & SpendableOutputDescriptor :: StaticOutputCounterpartyPayment ( ref descriptor) => {
171
+ & SpendableOutputDescriptor :: StaticPaymentOutput ( ref descriptor) => {
172
172
2u8 . write ( writer) ?;
173
173
descriptor. outpoint . write ( writer) ?;
174
174
descriptor. output . write ( writer) ?;
@@ -187,7 +187,7 @@ impl Readable for SpendableOutputDescriptor {
187
187
outpoint : Readable :: read ( reader) ?,
188
188
output : Readable :: read ( reader) ?,
189
189
} ) ,
190
- 1u8 => Ok ( SpendableOutputDescriptor :: DynamicOutputP2WSH ( DynamicP2WSHOutputDescriptor {
190
+ 1u8 => Ok ( SpendableOutputDescriptor :: DelayedPaymentOutput ( DelayedPaymentOutputDescriptor {
191
191
outpoint : Readable :: read ( reader) ?,
192
192
per_commitment_point : Readable :: read ( reader) ?,
193
193
to_self_delay : Readable :: read ( reader) ?,
@@ -196,7 +196,7 @@ impl Readable for SpendableOutputDescriptor {
196
196
channel_keys_id : Readable :: read ( reader) ?,
197
197
channel_value_satoshis : Readable :: read ( reader) ?,
198
198
} ) ) ,
199
- 2u8 => Ok ( SpendableOutputDescriptor :: StaticOutputCounterpartyPayment ( StaticCounterpartyPaymentOutputDescriptor {
199
+ 2u8 => Ok ( SpendableOutputDescriptor :: StaticPaymentOutput ( StaticPaymentOutputDescriptor {
200
200
outpoint : Readable :: read ( reader) ?,
201
201
output : Readable :: read ( reader) ?,
202
202
channel_keys_id : Readable :: read ( reader) ?,
@@ -496,7 +496,7 @@ impl InMemoryChannelKeys {
496
496
///
497
497
/// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
498
498
/// or is not spending the outpoint described by `descriptor.outpoint`.
499
- pub fn sign_counterparty_payment_input < C : Signing > ( & self , spend_tx : & Transaction , input_idx : usize , descriptor : & StaticCounterpartyPaymentOutputDescriptor , secp_ctx : & Secp256k1 < C > ) -> Result < Vec < Vec < u8 > > , ( ) > {
499
+ pub fn sign_counterparty_payment_input < C : Signing > ( & self , spend_tx : & Transaction , input_idx : usize , descriptor : & StaticPaymentOutputDescriptor , secp_ctx : & Secp256k1 < C > ) -> Result < Vec < Vec < u8 > > , ( ) > {
500
500
// TODO: We really should be taking the SigHashCache as a parameter here instead of
501
501
// spend_tx, but ideally the SigHashCache would expose the transaction's inputs read-only
502
502
// so that we can check them. This requires upstream rust-bitcoin changes (as well as
@@ -523,7 +523,7 @@ impl InMemoryChannelKeys {
523
523
/// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
524
524
/// is not spending the outpoint described by `descriptor.outpoint`, or does not have a
525
525
/// sequence set to `descriptor.to_self_delay`.
526
- pub fn sign_dynamic_p2wsh_input < C : Signing > ( & self , spend_tx : & Transaction , input_idx : usize , descriptor : & DynamicP2WSHOutputDescriptor , secp_ctx : & Secp256k1 < C > ) -> Result < Vec < Vec < u8 > > , ( ) > {
526
+ pub fn sign_dynamic_p2wsh_input < C : Signing > ( & self , spend_tx : & Transaction , input_idx : usize , descriptor : & DelayedPaymentOutputDescriptor , secp_ctx : & Secp256k1 < C > ) -> Result < Vec < Vec < u8 > > , ( ) > {
527
527
// TODO: We really should be taking the SigHashCache as a parameter here instead of
528
528
// spend_tx, but ideally the SigHashCache would expose the transaction's inputs read-only
529
529
// so that we can check them. This requires upstream rust-bitcoin changes (as well as
@@ -891,25 +891,25 @@ impl KeysManager {
891
891
let mut output_set = HashSet :: with_capacity ( descriptors. len ( ) ) ;
892
892
for outp in descriptors {
893
893
match outp {
894
- SpendableOutputDescriptor :: StaticOutputCounterpartyPayment ( descriptor) => {
894
+ SpendableOutputDescriptor :: StaticPaymentOutput ( descriptor) => {
895
895
input. push ( TxIn {
896
896
previous_output : descriptor. outpoint . into_bitcoin_outpoint ( ) ,
897
897
script_sig : Script :: new ( ) ,
898
898
sequence : 0 ,
899
899
witness : Vec :: new ( ) ,
900
900
} ) ;
901
- witness_weight += StaticCounterpartyPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
901
+ witness_weight += StaticPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
902
902
input_value += descriptor. output . value ;
903
903
if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
904
904
} ,
905
- SpendableOutputDescriptor :: DynamicOutputP2WSH ( descriptor) => {
905
+ SpendableOutputDescriptor :: DelayedPaymentOutput ( descriptor) => {
906
906
input. push ( TxIn {
907
907
previous_output : descriptor. outpoint . into_bitcoin_outpoint ( ) ,
908
908
script_sig : Script :: new ( ) ,
909
909
sequence : descriptor. to_self_delay as u32 ,
910
910
witness : Vec :: new ( ) ,
911
911
} ) ;
912
- witness_weight += DynamicP2WSHOutputDescriptor :: MAX_WITNESS_LENGTH ;
912
+ witness_weight += DelayedPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
913
913
input_value += descriptor. output . value ;
914
914
if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
915
915
} ,
@@ -939,15 +939,15 @@ impl KeysManager {
939
939
let mut input_idx = 0 ;
940
940
for outp in descriptors {
941
941
match outp {
942
- SpendableOutputDescriptor :: StaticOutputCounterpartyPayment ( descriptor) => {
942
+ SpendableOutputDescriptor :: StaticPaymentOutput ( descriptor) => {
943
943
if keys_cache. is_none ( ) || keys_cache. as_ref ( ) . unwrap ( ) . 1 != descriptor. channel_keys_id {
944
944
keys_cache = Some ( (
945
945
self . derive_channel_keys ( descriptor. channel_value_satoshis , & descriptor. channel_keys_id ) ,
946
946
descriptor. channel_keys_id ) ) ;
947
947
}
948
948
spend_tx. input [ input_idx] . witness = keys_cache. as_ref ( ) . unwrap ( ) . 0 . sign_counterparty_payment_input ( & spend_tx, input_idx, & descriptor, & secp_ctx) . unwrap ( ) ;
949
949
} ,
950
- SpendableOutputDescriptor :: DynamicOutputP2WSH ( descriptor) => {
950
+ SpendableOutputDescriptor :: DelayedPaymentOutput ( descriptor) => {
951
951
if keys_cache. is_none ( ) || keys_cache. as_ref ( ) . unwrap ( ) . 1 != descriptor. channel_keys_id {
952
952
keys_cache = Some ( (
953
953
self . derive_channel_keys ( descriptor. channel_value_satoshis , & descriptor. channel_keys_id ) ,
0 commit comments