Skip to content

Commit b6b6272

Browse files
committed
Fix more warnings.
1 parent f5a71ae commit b6b6272

File tree

8 files changed

+29
-23
lines changed

8 files changed

+29
-23
lines changed

lightning/src/sign/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,7 @@ impl EcdsaChannelSigner for InMemorySigner {
16991699
}
17001700

17011701
#[cfg(taproot)]
1702+
#[allow(unused)]
17021703
impl TaprootChannelSigner for InMemorySigner {
17031704
fn generate_local_nonce_pair(
17041705
&self, commitment_number: u64, secp_ctx: &Secp256k1<All>,

lightning/src/util/macro_logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'a> core::fmt::Display for DebugTx<'a> {
107107
debug_assert!(false, "We should never generate unknown transaction types");
108108
write!(f, "unknown tx type ").unwrap();
109109
}
110-
write!(f, "with txid {}", self.0.txid())?;
110+
write!(f, "with txid {}", self.0.compute_wtxid())?;
111111
Ok(())
112112
}
113113
}

lightning/src/util/ser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ impl<'a, T: Writeable> Writeable for WithoutLength<&'a Vec<T>> {
776776

777777
impl<T: MaybeReadable> Readable for WithoutLength<Vec<T>> {
778778
#[inline]
779-
fn read<R: Read>(mut reader: &mut R) -> Result<Self, DecodeError> {
779+
fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
780780
let mut values = Vec::new();
781781
loop {
782782
let mut track_read = ReadTrackingReader::new(reader);

lightning/src/util/ser_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ macro_rules! _decode_tlv_stream_range {
509509
$(, $decode_custom_tlv: expr)?) => { {
510510
use $crate::ln::msgs::DecodeError;
511511
let mut last_seen_type: Option<u64> = None;
512-
let mut stream_ref = $stream;
512+
let stream_ref = $stream;
513513
'tlv_read: loop {
514514
use $crate::util::ser;
515515

lightning/src/util/sweep.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ where
500500
log_debug!(
501501
self.logger,
502502
"Generating and broadcasting sweeping transaction {}",
503-
spending_tx.txid()
503+
spending_tx.compute_txid()
504504
);
505505
spending_tx
506506
},
@@ -534,7 +534,7 @@ where
534534
if cur_height >= confirmation_height + ANTI_REORG_DELAY - 1 {
535535
log_debug!(self.logger,
536536
"Pruning swept output as sufficiently confirmed via spend in transaction {:?}. Pruned descriptor: {:?}",
537-
o.status.latest_spending_tx().map(|t| t.txid()), o.descriptor
537+
o.status.latest_spending_tx().map(|t| t.compute_txid()), o.descriptor
538538
);
539539
return false;
540540
}
@@ -697,7 +697,7 @@ where
697697
let unconf_height = state_lock
698698
.outputs
699699
.iter()
700-
.find(|o| o.status.latest_spending_tx().map(|tx| tx.txid()) == Some(*txid))
700+
.find(|o| o.status.latest_spending_tx().map(|tx| tx.compute_txid()) == Some(*txid))
701701
.and_then(|o| o.status.confirmation_height());
702702

703703
if let Some(unconf_height) = unconf_height {
@@ -742,7 +742,11 @@ where
742742
confirmation_height,
743743
confirmation_hash,
744744
..
745-
} => Some((latest_spending_tx.txid(), confirmation_height, Some(confirmation_hash))),
745+
} => Some((
746+
latest_spending_tx.compute_txid(),
747+
confirmation_height,
748+
Some(confirmation_hash),
749+
)),
746750
_ => None,
747751
})
748752
.collect::<Vec<_>>()

lightning/src/util/test_channel_signer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use bitcoin::secp256k1::All;
3333
use bitcoin::secp256k1::{SecretKey, PublicKey};
3434
use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature};
3535
#[cfg(taproot)]
36-
use musig2::types::{PartialSignature, PublicNonce, SecretNonce};
36+
use musig2::types::{PartialSignature, PublicNonce};
3737
use crate::sign::HTLCDescriptor;
3838
use crate::util::ser::{Writeable, Writer};
3939
use crate::io::Error;
@@ -352,6 +352,7 @@ impl EcdsaChannelSigner for TestChannelSigner {
352352
}
353353

354354
#[cfg(taproot)]
355+
#[allow(unused)]
355356
impl TaprootChannelSigner for TestChannelSigner {
356357
fn generate_local_nonce_pair(&self, commitment_number: u64, secp_ctx: &Secp256k1<All>) -> PublicNonce {
357358
todo!()

lightning/src/util/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ impl TestBroadcaster {
733733
pub fn unique_txn_broadcast(&self) -> Vec<Transaction> {
734734
let mut txn = self.txn_broadcasted.lock().unwrap().split_off(0);
735735
let mut seen = new_hash_set();
736-
txn.retain(|tx| seen.insert(tx.txid()));
736+
txn.retain(|tx| seen.insert(tx.compute_txid()));
737737
txn
738738
}
739739
}

lightning/src/util/transaction_utils.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub(crate) fn maybe_add_change_output(tx: &mut Transaction, input_value: Amount,
4545
if output_value >= input_value { return Err(()); }
4646
}
4747

48-
let dust_value = change_destination_script.dust_value();
48+
let dust_value = change_destination_script.minimal_non_dust();
4949
let mut change_output = TxOut {
5050
script_pubkey: change_destination_script,
5151
value: Amount::ZERO,
@@ -227,27 +227,27 @@ mod tests {
227227
fn test_tx_change_edge() {
228228
// Check that we never add dust outputs
229229
let mut tx = Transaction { version: Version::TWO, lock_time: LockTime::ZERO, input: Vec::new(), output: Vec::new() };
230-
let orig_wtxid = tx.wtxid();
230+
let orig_wtxid = tx.compute_wtxid();
231231
let output_spk = ScriptBuf::new_p2pkh(&PubkeyHash::hash(&[0; 0]));
232-
assert_eq!(output_spk.dust_value().to_sat(), 546);
232+
assert_eq!(output_spk.minimal_non_dust().to_sat(), 546);
233233
// base size = version size + varint[input count] + input size + varint[output count] + output size + lock time size
234234
// total size = version size + marker + flag + varint[input count] + input size + varint[output count] + output size + lock time size
235235
// weight = 3 * base size + total size = 3 * (4 + 1 + 0 + 1 + 0 + 4) + (4 + 1 + 1 + 1 + 0 + 1 + 0 + 4) = 3 * 10 + 12 = 42
236236
assert_eq!(tx.weight().to_wu(), 42);
237237
// 10 sats isn't enough to pay fee on a dummy transaction...
238238
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(10), 0, 250, output_spk.clone()).is_err());
239-
assert_eq!(tx.wtxid(), orig_wtxid); // Failure doesn't change the transaction
239+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // Failure doesn't change the transaction
240240
// but 11 (= ceil(42 * 250 / 1000)) is, just not enough to add a change output...
241241
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(11), 0, 250, output_spk.clone()).is_ok());
242242
assert_eq!(tx.output.len(), 0);
243-
assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
243+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
244244
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(549), 0, 250, output_spk.clone()).is_ok());
245245
assert_eq!(tx.output.len(), 0);
246-
assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
246+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
247247
// 590 is also not enough
248248
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(590), 0, 250, output_spk.clone()).is_ok());
249249
assert_eq!(tx.output.len(), 0);
250-
assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
250+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
251251
// at 591 we can afford the change output at the dust limit (546)
252252
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(591), 0, 250, output_spk.clone()).is_ok());
253253
assert_eq!(tx.output.len(), 1);
@@ -256,7 +256,7 @@ mod tests {
256256
assert_eq!(tx.weight().to_wu() / 4, 590-546); // New weight is exactly the fee we wanted.
257257

258258
tx.output.pop();
259-
assert_eq!(tx.wtxid(), orig_wtxid); // The only change is the addition of one output.
259+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // The only change is the addition of one output.
260260
}
261261

262262
#[test]
@@ -267,28 +267,28 @@ mod tests {
267267
}], output: vec![TxOut {
268268
script_pubkey: Builder::new().push_int(1).into_script(), value: Amount::from_sat(1000)
269269
}] };
270-
let orig_wtxid = tx.wtxid();
270+
let orig_wtxid = tx.compute_wtxid();
271271
let orig_weight = tx.weight().to_wu();
272272
assert_eq!(orig_weight / 4, 61);
273273

274-
assert_eq!(Builder::new().push_int(2).into_script().dust_value().to_sat(), 474);
274+
assert_eq!(Builder::new().push_int(2).into_script().minimal_non_dust().to_sat(), 474);
275275

276276
// Input value of the output value + fee - 1 should fail:
277277
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(1000 + 61 + 100 - 1), 400, 250, Builder::new().push_int(2).into_script()).is_err());
278-
assert_eq!(tx.wtxid(), orig_wtxid); // Failure doesn't change the transaction
278+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // Failure doesn't change the transaction
279279
// but one more input sat should succeed, without changing the transaction
280280
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(1000 + 61 + 100), 400, 250, Builder::new().push_int(2).into_script()).is_ok());
281-
assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
281+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
282282
// In order to get a change output, we need to add 474 plus the output's weight / 4 (10)...
283283
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(1000 + 61 + 100 + 474 + 9), 400, 250, Builder::new().push_int(2).into_script()).is_ok());
284-
assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
284+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
285285

286286
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(1000 + 61 + 100 + 474 + 10), 400, 250, Builder::new().push_int(2).into_script()).is_ok());
287287
assert_eq!(tx.output.len(), 2);
288288
assert_eq!(tx.output[1].value.to_sat(), 474);
289289
assert_eq!(tx.output[1].script_pubkey, Builder::new().push_int(2).into_script());
290290
assert_eq!(tx.weight().to_wu() - orig_weight, 40); // Weight difference matches what we had to add above
291291
tx.output.pop();
292-
assert_eq!(tx.wtxid(), orig_wtxid); // The only change is the addition of one output.
292+
assert_eq!(tx.compute_wtxid(), orig_wtxid); // The only change is the addition of one output.
293293
}
294294
}

0 commit comments

Comments
 (0)