The `TxId` argument to `EphemeralAddressReuse` does not need to be optional.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira-Emma Hopwood 2024-07-04 20:37:07 +01:00
parent bda6451273
commit 22b8cff6d1
2 changed files with 5 additions and 7 deletions

View File

@ -121,10 +121,10 @@ pub enum SqliteClientError {
ReachedGapLimit(AccountId, u32),
/// An ephemeral address would be reused. The parameters are the address in string
/// form, and if it is known to have been used in one or more previous transactions,
/// the txid of the earliest of those transactions.
/// form, and the txid of the earliest transaction in which it is known to have been
/// used.
#[cfg(feature = "transparent-inputs")]
EphemeralAddressReuse(String, Option<TxId>),
EphemeralAddressReuse(String, TxId),
}
impl error::Error for SqliteClientError {
@ -181,9 +181,7 @@ impl fmt::Display for SqliteClientError {
The ephemeral address in account {account_id:?} at index {bad_index} could not be safely reserved.",
),
#[cfg(feature = "transparent-inputs")]
SqliteClientError::EphemeralAddressReuse(address_str, Some(txid)) => write!(f, "The ephemeral address {address_str} previously used in txid {txid} would be reused."),
#[cfg(feature = "transparent-inputs")]
SqliteClientError::EphemeralAddressReuse(address_str, None) => write!(f, "The ephemeral address {address_str} would be reused."),
SqliteClientError::EphemeralAddressReuse(address_str, txid) => write!(f, "The ephemeral address {address_str} previously used in txid {txid} would be reused."),
}
}
}

View File

@ -338,7 +338,7 @@ fn ephemeral_address_reuse_check<P: consensus::Parameters>(
);
Err(SqliteClientError::EphemeralAddressReuse(
address_str.to_owned(),
Some(txid),
txid,
))
} else {
Ok(())