Skip to content

Commit

Permalink
commands: remove redundant output value check
Browse files Browse the repository at this point in the history
It's already performed (twice) in spend::create_psbt()
  • Loading branch information
darosior committed Nov 30, 2023
1 parent 0581e32 commit d58e3cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::{
database::{Coin, DatabaseConnection, DatabaseInterface},
descriptors,
spend::{
check_output_value, create_spend, AddrInfo, CandidateCoin, CreateSpendRes, InsaneFeeInfo,
SpendCreationError, SpendOutputAddress, TxGetter,
create_spend, AddrInfo, CandidateCoin, CreateSpendRes, InsaneFeeInfo, SpendCreationError,
SpendOutputAddress, TxGetter,
},
DaemonControl, VERSION,
};
Expand Down Expand Up @@ -441,13 +441,11 @@ impl DaemonControl {
let mut db_conn = self.db.connection();
let mut tx_getter = BitcoindTxGetter::new(&self.bitcoin);

// Check the destination addresses are valid for the network and
// sanity check each output's value.
// Prepare the destination addresses.
let mut destinations_checked = Vec::with_capacity(destinations.len());
for (address, value_sat) in destinations {
let address = self.validate_address(address.clone())?;
let amount = bitcoin::Amount::from_sat(*value_sat);
check_output_value(amount)?;
let address = self.spend_addr(&mut db_conn, address);
destinations_checked.push((address, amount));
}
Expand Down
2 changes: 1 addition & 1 deletion src/spend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl fmt::Display for SpendCreationError {
impl std::error::Error for SpendCreationError {}

// Sanity check the value of a transaction output.
pub fn check_output_value(value: bitcoin::Amount) -> Result<(), SpendCreationError> {
fn check_output_value(value: bitcoin::Amount) -> Result<(), SpendCreationError> {
// NOTE: the network parameter isn't used upstream
if value.to_sat() > bitcoin::blockdata::constants::MAX_MONEY
|| value.to_sat() < DUST_OUTPUT_SATS
Expand Down

0 comments on commit d58e3cb

Please sign in to comment.