@@ -2269,24 +2269,24 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22692269 };
22702270
22712271 // Optionally add change output
2272+ let change_script = if let Some(script) = change_destination_opt {
2273+ script
2274+ } else {
2275+ signer_provider.get_destination_script(self.context.channel_keys_id)
2276+ .map_err(|err| ChannelError::Warn(format!(
2277+ "Failed to get change script as new destination script, {:?}", err,
2278+ )))?
2279+ };
22722280 let change_value_opt = calculate_change_output_value(
22732281 self.funding.is_outbound(), self.dual_funding_context.our_funding_satoshis,
22742282 &funding_inputs_prev_outputs, &funding_outputs,
22752283 self.dual_funding_context.funding_feerate_sat_per_1000_weight,
2276- self.context.holder_dust_limit_satoshis ,
2284+ change_script.minimal_non_dust().to_sat() ,
22772285 ).map_err(|err| ChannelError::Warn(format!(
22782286 "Insufficient inputs, cannot cover intended contribution of {} and fees; {}",
22792287 self.dual_funding_context.our_funding_satoshis, err
22802288 )))?;
22812289 if let Some(change_value) = change_value_opt {
2282- let change_script = if let Some(script) = change_destination_opt {
2283- script
2284- } else {
2285- signer_provider.get_destination_script(self.context.channel_keys_id)
2286- .map_err(|err| ChannelError::Warn(format!(
2287- "Failed to get change script as new destination script, {:?}", err,
2288- )))?
2289- };
22902290 let mut change_output = TxOut {
22912291 value: Amount::from_sat(change_value),
22922292 script_pubkey: change_script,
0 commit comments