Skip to content

Commit 00d063d

Browse files
author
Antoine Riard
committed
Overhaul ChannelMonitor/OnchainTxHandler to new nomenclature
1 parent 9a23130 commit 00d063d

File tree

11 files changed

+542
-542
lines changed

11 files changed

+542
-542
lines changed

fuzz/src/full_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,6 @@ mod tests {
903903
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030200000000000000000000000000000000000000000000000000000000000000 with 1 adds, 0 fulfills, 0 fails for channel 3900000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&3)); // 7
904904
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000000 with 0 adds, 1 fulfills, 0 fails for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1)); // 8
905905
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000000 with 0 adds, 0 fulfills, 1 fails for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&2)); // 9
906-
assert_eq!(log_entries.get(&("lightning::ln::channelmonitor".to_string(), "Input spending remote commitment tx (00000000000000000000000000000000000000000000000000000000000000a1:0) in 0000000000000000000000000000000000000000000000000000000000000018 resolves outbound HTLC with payment hash ff00000000000000000000000000000000000000000000000000000000000000 with timeout".to_string())), Some(&1)); // 10
906+
assert_eq!(log_entries.get(&("lightning::ln::channelmonitor".to_string(), "Input spending counterparty commitment tx (00000000000000000000000000000000000000000000000000000000000000a1:0) in 0000000000000000000000000000000000000000000000000000000000000018 resolves outbound HTLC with payment hash ff00000000000000000000000000000000000000000000000000000000000000 with timeout".to_string())), Some(&1)); // 10
907907
}
908908
}

lightning-c-bindings/src/chain/keysinterface.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub enum SpendableOutputDescriptor {
4343
/// using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in
4444
/// ChannelKeys::pubkeys().
4545
///
46-
/// To derive the remote_revocation_pubkey provided here (which is used in the witness
46+
/// To derive the counterparty_revocation_pubkey provided here (which is used in the witness
4747
/// script generation), you must pass the remote revocation_basepoint (which appears in the
4848
/// call to ChannelKeys::on_accept) and the provided per_commitment point
4949
/// to chan_utils::derive_public_revocation_key.
@@ -58,7 +58,7 @@ pub enum SpendableOutputDescriptor {
5858
to_self_delay: u16,
5959
output: crate::c_types::TxOut,
6060
key_derivation_params: crate::c_types::derived::C2Tuple_u64u64Z,
61-
remote_revocation_pubkey: crate::c_types::PublicKey,
61+
counterparty_revocation_pubkey: crate::c_types::PublicKey,
6262
},
6363
/// An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
6464
/// corresponds to the public key in ChannelKeys::pubkeys().payment_point).
@@ -67,7 +67,7 @@ pub enum SpendableOutputDescriptor {
6767
///
6868
/// These are generally the result of our counterparty having broadcast the current state,
6969
/// allowing us to claim the non-HTLC-encumbered outputs immediately.
70-
StaticOutputRemotePayment {
70+
StaticOutputCounterpartyPayment {
7171
outpoint: crate::chain::transaction::OutPoint,
7272
output: crate::c_types::TxOut,
7373
key_derivation_params: crate::c_types::derived::C2Tuple_u64u64Z,
@@ -86,29 +86,29 @@ impl SpendableOutputDescriptor {
8686
output: output_nonref.into_rust(),
8787
}
8888
},
89-
SpendableOutputDescriptor::DynamicOutputP2WSH {ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref remote_revocation_pubkey, } => {
89+
SpendableOutputDescriptor::DynamicOutputP2WSH {ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref counterparty_revocation_pubkey, } => {
9090
let mut outpoint_nonref = (*outpoint).clone();
9191
let mut per_commitment_point_nonref = (*per_commitment_point).clone();
9292
let mut to_self_delay_nonref = (*to_self_delay).clone();
9393
let mut output_nonref = (*output).clone();
9494
let mut key_derivation_params_nonref = (*key_derivation_params).clone();
9595
let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref.to_rust(); let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1);
96-
let mut remote_revocation_pubkey_nonref = (*remote_revocation_pubkey).clone();
96+
let mut counterparty_revocation_pubkey_nonref = (*counterparty_revocation_pubkey).clone();
9797
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {
9898
outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_ptr()) },
9999
per_commitment_point: per_commitment_point_nonref.into_rust(),
100100
to_self_delay: to_self_delay_nonref,
101101
output: output_nonref.into_rust(),
102102
key_derivation_params: local_key_derivation_params_nonref,
103-
remote_revocation_pubkey: remote_revocation_pubkey_nonref.into_rust(),
103+
counterparty_revocation_pubkey: counterparty_revocation_pubkey_nonref.into_rust(),
104104
}
105105
},
106-
SpendableOutputDescriptor::StaticOutputRemotePayment {ref outpoint, ref output, ref key_derivation_params, } => {
106+
SpendableOutputDescriptor::StaticOutputCounterpartyPayment {ref outpoint, ref output, ref key_derivation_params, } => {
107107
let mut outpoint_nonref = (*outpoint).clone();
108108
let mut output_nonref = (*output).clone();
109109
let mut key_derivation_params_nonref = (*key_derivation_params).clone();
110110
let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref.to_rust(); let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1);
111-
nativeSpendableOutputDescriptor::StaticOutputRemotePayment {
111+
nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment {
112112
outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_ptr()) },
113113
output: output_nonref.into_rust(),
114114
key_derivation_params: local_key_derivation_params_nonref,
@@ -125,20 +125,20 @@ impl SpendableOutputDescriptor {
125125
output: output.into_rust(),
126126
}
127127
},
128-
SpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut key_derivation_params, mut remote_revocation_pubkey, } => {
128+
SpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut key_derivation_params, mut counterparty_revocation_pubkey, } => {
129129
let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params.to_rust(); let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1);
130130
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {
131131
outpoint: *unsafe { Box::from_raw(outpoint.take_ptr()) },
132132
per_commitment_point: per_commitment_point.into_rust(),
133133
to_self_delay: to_self_delay,
134134
output: output.into_rust(),
135135
key_derivation_params: local_key_derivation_params,
136-
remote_revocation_pubkey: remote_revocation_pubkey.into_rust(),
136+
counterparty_revocation_pubkey: counterparty_revocation_pubkey.into_rust(),
137137
}
138138
},
139-
SpendableOutputDescriptor::StaticOutputRemotePayment {mut outpoint, mut output, mut key_derivation_params, } => {
139+
SpendableOutputDescriptor::StaticOutputCounterpartyPayment {mut outpoint, mut output, mut key_derivation_params, } => {
140140
let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params.to_rust(); let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1);
141-
nativeSpendableOutputDescriptor::StaticOutputRemotePayment {
141+
nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment {
142142
outpoint: *unsafe { Box::from_raw(outpoint.take_ptr()) },
143143
output: output.into_rust(),
144144
key_derivation_params: local_key_derivation_params,
@@ -157,29 +157,29 @@ impl SpendableOutputDescriptor {
157157
output: crate::c_types::TxOut::from_rust(output_nonref),
158158
}
159159
},
160-
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref remote_revocation_pubkey, } => {
160+
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref counterparty_revocation_pubkey, } => {
161161
let mut outpoint_nonref = (*outpoint).clone();
162162
let mut per_commitment_point_nonref = (*per_commitment_point).clone();
163163
let mut to_self_delay_nonref = (*to_self_delay).clone();
164164
let mut output_nonref = (*output).clone();
165165
let mut key_derivation_params_nonref = (*key_derivation_params).clone();
166166
let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref; let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1).into();
167-
let mut remote_revocation_pubkey_nonref = (*remote_revocation_pubkey).clone();
167+
let mut counterparty_revocation_pubkey_nonref = (*counterparty_revocation_pubkey).clone();
168168
SpendableOutputDescriptor::DynamicOutputP2WSH {
169169
outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint_nonref)), is_owned: true },
170170
per_commitment_point: crate::c_types::PublicKey::from_rust(&per_commitment_point_nonref),
171171
to_self_delay: to_self_delay_nonref,
172172
output: crate::c_types::TxOut::from_rust(output_nonref),
173173
key_derivation_params: local_key_derivation_params_nonref,
174-
remote_revocation_pubkey: crate::c_types::PublicKey::from_rust(&remote_revocation_pubkey_nonref),
174+
counterparty_revocation_pubkey: crate::c_types::PublicKey::from_rust(&counterparty_revocation_pubkey_nonref),
175175
}
176176
},
177-
nativeSpendableOutputDescriptor::StaticOutputRemotePayment {ref outpoint, ref output, ref key_derivation_params, } => {
177+
nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment {ref outpoint, ref output, ref key_derivation_params, } => {
178178
let mut outpoint_nonref = (*outpoint).clone();
179179
let mut output_nonref = (*output).clone();
180180
let mut key_derivation_params_nonref = (*key_derivation_params).clone();
181181
let (mut orig_key_derivation_params_nonref_0, mut orig_key_derivation_params_nonref_1) = key_derivation_params_nonref; let mut local_key_derivation_params_nonref = (orig_key_derivation_params_nonref_0, orig_key_derivation_params_nonref_1).into();
182-
SpendableOutputDescriptor::StaticOutputRemotePayment {
182+
SpendableOutputDescriptor::StaticOutputCounterpartyPayment {
183183
outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint_nonref)), is_owned: true },
184184
output: crate::c_types::TxOut::from_rust(output_nonref),
185185
key_derivation_params: local_key_derivation_params_nonref,
@@ -196,20 +196,20 @@ impl SpendableOutputDescriptor {
196196
output: crate::c_types::TxOut::from_rust(output),
197197
}
198198
},
199-
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut key_derivation_params, mut remote_revocation_pubkey, } => {
199+
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut key_derivation_params, mut counterparty_revocation_pubkey, } => {
200200
let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params; let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1).into();
201201
SpendableOutputDescriptor::DynamicOutputP2WSH {
202202
outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint)), is_owned: true },
203203
per_commitment_point: crate::c_types::PublicKey::from_rust(&per_commitment_point),
204204
to_self_delay: to_self_delay,
205205
output: crate::c_types::TxOut::from_rust(output),
206206
key_derivation_params: local_key_derivation_params,
207-
remote_revocation_pubkey: crate::c_types::PublicKey::from_rust(&remote_revocation_pubkey),
207+
counterparty_revocation_pubkey: crate::c_types::PublicKey::from_rust(&counterparty_revocation_pubkey),
208208
}
209209
},
210-
nativeSpendableOutputDescriptor::StaticOutputRemotePayment {mut outpoint, mut output, mut key_derivation_params, } => {
210+
nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment {mut outpoint, mut output, mut key_derivation_params, } => {
211211
let (mut orig_key_derivation_params_0, mut orig_key_derivation_params_1) = key_derivation_params; let mut local_key_derivation_params = (orig_key_derivation_params_0, orig_key_derivation_params_1).into();
212-
SpendableOutputDescriptor::StaticOutputRemotePayment {
212+
SpendableOutputDescriptor::StaticOutputCounterpartyPayment {
213213
outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint)), is_owned: true },
214214
output: crate::c_types::TxOut::from_rust(output),
215215
key_derivation_params: local_key_derivation_params,

lightning-c-bindings/src/ln/channelmonitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut Cha
542542
/// In any-case, choice is up to the user.
543543
#[must_use]
544544
#[no_mangle]
545-
pub extern "C" fn ChannelMonitor_get_latest_local_commitment_txn(this_arg: &mut ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
546-
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_local_commitment_txn(logger);
545+
pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
546+
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_holder_commitment_txn(logger);
547547
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); local_ret_0.into() }); };
548548
local_ret.into()
549549
}

lightning/src/chain/keysinterface.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ pub enum SpendableOutputDescriptor {
7171
/// it is an output from an old state which we broadcast (which should never happen).
7272
///
7373
/// To derive the delayed_payment key which is used to sign for this input, you must pass the
74-
/// local delayed_payment_base_key (ie the private key which corresponds to the pubkey in
74+
/// holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in
7575
/// ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to
7676
/// chan_utils::derive_private_key. The public key can be generated without the secret key
7777
/// using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in
7878
/// ChannelKeys::pubkeys().
7979
///
80-
/// To derive the remote_revocation_pubkey provided here (which is used in the witness
81-
/// script generation), you must pass the remote revocation_basepoint (which appears in the
80+
/// To derive the counterparty_revocation_pubkey provided here (which is used in the witness
81+
/// script generation), you must pass the counterparty revocation_basepoint (which appears in the
8282
/// call to ChannelKeys::on_accept) and the provided per_commitment point
8383
/// to chan_utils::derive_public_revocation_key.
8484
///
@@ -101,8 +101,8 @@ pub enum SpendableOutputDescriptor {
101101
/// The channel keys state used to proceed to derivation of signing key. Must
102102
/// be pass to KeysInterface::derive_channel_keys.
103103
key_derivation_params: (u64, u64),
104-
/// The remote_revocation_pubkey used to derive witnessScript
105-
remote_revocation_pubkey: PublicKey
104+
/// The counterparty_revocation_pubkey used to derive witnessScript
105+
counterparty_revocation_pubkey: PublicKey
106106
},
107107
/// An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
108108
/// corresponds to the public key in ChannelKeys::pubkeys().payment_point).
@@ -111,7 +111,7 @@ pub enum SpendableOutputDescriptor {
111111
///
112112
/// These are generally the result of our counterparty having broadcast the current state,
113113
/// allowing us to claim the non-HTLC-encumbered outputs immediately.
114-
StaticOutputRemotePayment {
114+
StaticOutputCounterpartyPayment {
115115
/// The outpoint which is spendable
116116
outpoint: OutPoint,
117117
/// The output which is reference by the given outpoint
@@ -130,17 +130,17 @@ impl Writeable for SpendableOutputDescriptor {
130130
outpoint.write(writer)?;
131131
output.write(writer)?;
132132
},
133-
&SpendableOutputDescriptor::DynamicOutputP2WSH { ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref remote_revocation_pubkey } => {
133+
&SpendableOutputDescriptor::DynamicOutputP2WSH { ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref key_derivation_params, ref counterparty_revocation_pubkey } => {
134134
1u8.write(writer)?;
135135
outpoint.write(writer)?;
136136
per_commitment_point.write(writer)?;
137137
to_self_delay.write(writer)?;
138138
output.write(writer)?;
139139
key_derivation_params.0.write(writer)?;
140140
key_derivation_params.1.write(writer)?;
141-
remote_revocation_pubkey.write(writer)?;
141+
counterparty_revocation_pubkey.write(writer)?;
142142
},
143-
&SpendableOutputDescriptor::StaticOutputRemotePayment { ref outpoint, ref output, ref key_derivation_params } => {
143+
&SpendableOutputDescriptor::StaticOutputCounterpartyPayment { ref outpoint, ref output, ref key_derivation_params } => {
144144
2u8.write(writer)?;
145145
outpoint.write(writer)?;
146146
output.write(writer)?;
@@ -165,9 +165,9 @@ impl Readable for SpendableOutputDescriptor {
165165
to_self_delay: Readable::read(reader)?,
166166
output: Readable::read(reader)?,
167167
key_derivation_params: (Readable::read(reader)?, Readable::read(reader)?),
168-
remote_revocation_pubkey: Readable::read(reader)?,
168+
counterparty_revocation_pubkey: Readable::read(reader)?,
169169
}),
170-
2u8 => Ok(SpendableOutputDescriptor::StaticOutputRemotePayment {
170+
2u8 => Ok(SpendableOutputDescriptor::StaticOutputCounterpartyPayment {
171171
outpoint: Readable::read(reader)?,
172172
output: Readable::read(reader)?,
173173
key_derivation_params: (Readable::read(reader)?, Readable::read(reader)?),

0 commit comments

Comments
 (0)