commands: remove redundant output value check

It's already performed (twice) in spend::create_psbt()
This commit is contained in:
Antoine Poinsot 2023-11-30 12:20:26 +01:00
parent 5894e788b8
commit f3113ba0d2
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
2 changed files with 4 additions and 6 deletions

View File

@ -9,8 +9,8 @@ use crate::{
database::{Coin, DatabaseConnection, DatabaseInterface},
descriptors,
spend::{
check_output_value, create_spend, AddrInfo, CandidateCoin, CreateSpendRes,
SpendCreationError, SpendOutputAddress, TxGetter,
create_spend, AddrInfo, CandidateCoin, CreateSpendRes, SpendCreationError,
SpendOutputAddress, TxGetter,
},
DaemonControl, VERSION,
};
@ -443,13 +443,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));
}

View File

@ -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