Skip to content

Commit 52c63d6

Browse files
committed
Replace ToHex use with explicit string conversion
1 parent c308c6b commit 52c63d6

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,9 +1980,9 @@ mod tests {
19801980
assert_eq!(tx.built.transaction.output.len(), 3);
19811981
assert_eq!(tx.built.transaction.output[0].script_pubkey, get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::only_static_remote_key(), &keys).to_v0_p2wsh());
19821982
assert_eq!(tx.built.transaction.output[1].script_pubkey, get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::only_static_remote_key(), &keys).to_v0_p2wsh());
1983-
assert_eq!(get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::only_static_remote_key(), &keys).to_v0_p2wsh().to_hex(),
1983+
assert_eq!(get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::only_static_remote_key(), &keys).to_v0_p2wsh().to_hex_string(),
19841984
"0020e43a7c068553003fe68fcae424fb7b28ec5ce48cd8b6744b3945631389bad2fb");
1985-
assert_eq!(get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::only_static_remote_key(), &keys).to_v0_p2wsh().to_hex(),
1985+
assert_eq!(get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::only_static_remote_key(), &keys).to_v0_p2wsh().to_hex_string(),
19861986
"0020215d61bba56b19e9eadb6107f5a85d7f99c40f65992443f69229c290165bc00d");
19871987

19881988
// Generate broadcaster output and received and offered HTLC outputs, with anchors
@@ -1992,9 +1992,9 @@ mod tests {
19921992
assert_eq!(tx.built.transaction.output.len(), 5);
19931993
assert_eq!(tx.built.transaction.output[2].script_pubkey, get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_v0_p2wsh());
19941994
assert_eq!(tx.built.transaction.output[3].script_pubkey, get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_v0_p2wsh());
1995-
assert_eq!(get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_v0_p2wsh().to_hex(),
1995+
assert_eq!(get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_v0_p2wsh().to_hex_string(),
19961996
"0020b70d0649c72b38756885c7a30908d912a7898dd5d79457a7280b8e9a20f3f2bc");
1997-
assert_eq!(get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_v0_p2wsh().to_hex(),
1997+
assert_eq!(get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_v0_p2wsh().to_hex_string(),
19981998
"002087a3faeb1950a469c0e2db4a79b093a41b9526e5a6fc6ef5cb949bde3be379c7");
19991999
}
20002000

lightning/src/ln/channel.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ use core::convert::TryInto;
5353
use core::ops::Deref;
5454
#[cfg(any(test, fuzzing, debug_assertions))]
5555
use crate::sync::Mutex;
56-
use bitcoin::hashes::hex::ToHex;
5756
use crate::sign::type_resolver::ChannelSignerType;
5857

5958
#[cfg(test)]
@@ -4474,12 +4473,12 @@ impl<SP: Deref> Channel<SP> where
44744473
assert_eq!(self.context.channel_state & ChannelState::ShutdownComplete as u32, 0);
44754474

44764475
if !script::is_bolt2_compliant(&msg.scriptpubkey, their_features) {
4477-
return Err(ChannelError::Warn(format!("Got a nonstandard scriptpubkey ({}) from remote peer", msg.scriptpubkey.to_bytes().to_hex())));
4476+
return Err(ChannelError::Warn(format!("Got a nonstandard scriptpubkey ({}) from remote peer", msg.scriptpubkey.to_hex_string())));
44784477
}
44794478

44804479
if self.context.counterparty_shutdown_scriptpubkey.is_some() {
44814480
if Some(&msg.scriptpubkey) != self.context.counterparty_shutdown_scriptpubkey.as_ref() {
4482-
return Err(ChannelError::Warn(format!("Got shutdown request with a scriptpubkey ({}) which did not match their previous scriptpubkey.", msg.scriptpubkey.to_bytes().to_hex())));
4481+
return Err(ChannelError::Warn(format!("Got shutdown request with a scriptpubkey ({}) which did not match their previous scriptpubkey.", msg.scriptpubkey.to_hex_string())));
44834482
}
44844483
} else {
44854484
self.context.counterparty_shutdown_scriptpubkey = Some(msg.scriptpubkey.clone());

lightning/src/routing/utxo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl PendingChecks {
464464
if script_pubkey != expected_script {
465465
return Err(LightningError{
466466
err: format!("Channel announcement key ({}) didn't match on-chain script ({})",
467-
expected_script.to_hex(), script_pubkey.to_hex()),
467+
expected_script.to_hex_string(), script_pubkey.to_hex_string()),
468468
action: ErrorAction::IgnoreError
469469
});
470470
}

lightning/src/util/persist.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use core::cmp;
1212
use core::convert::{TryFrom, TryInto};
1313
use core::ops::Deref;
14-
use bitcoin::hashes::hex::ToHex;
1514
use core::str::FromStr;
1615
use bitcoin::{BlockHash, Txid};
1716

@@ -195,7 +194,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner, K: KVStore> Persist<ChannelSign
195194
// just shut down the node since we're not retrying persistence!
196195

197196
fn persist_new_channel(&self, funding_txo: OutPoint, monitor: &ChannelMonitor<ChannelSigner>, _update_id: MonitorUpdateId) -> chain::ChannelMonitorUpdateStatus {
198-
let key = format!("{}_{}", funding_txo.txid.to_hex(), funding_txo.index);
197+
let key = format!("{}_{}", funding_txo.txid.to_string(), funding_txo.index);
199198
match self.write(
200199
CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE,
201200
CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE,
@@ -207,7 +206,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner, K: KVStore> Persist<ChannelSign
207206
}
208207

209208
fn update_persisted_channel(&self, funding_txo: OutPoint, _update: Option<&ChannelMonitorUpdate>, monitor: &ChannelMonitor<ChannelSigner>, _update_id: MonitorUpdateId) -> chain::ChannelMonitorUpdateStatus {
210-
let key = format!("{}_{}", funding_txo.txid.to_hex(), funding_txo.index);
209+
let key = format!("{}_{}", funding_txo.txid.to_string(), funding_txo.index);
211210
match self.write(
212211
CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE,
213212
CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE,
@@ -814,7 +813,7 @@ impl TryFrom<&MonitorName> for OutPoint {
814813

815814
impl From<OutPoint> for MonitorName {
816815
fn from(value: OutPoint) -> Self {
817-
MonitorName(format!("{}_{}", value.txid.to_hex(), value.index))
816+
MonitorName(format!("{}_{}", value.txid.to_string(), value.index))
818817
}
819818
}
820819

0 commit comments

Comments
 (0)