Skip to content

Commit 2302cc6

Browse files
EthanYuanjjyr
authored andcommitted
update spend_spendable_outputs
1 parent c8e2a62 commit 2302cc6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mutiny-core/src/event.rs

+1
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ impl<S: MutinyStorage> EventHandler<S> {
873873
tx_feerate,
874874
locktime,
875875
&Secp256k1::new(),
876+
self.sweep_target_address.clone(),
876877
)
877878
.map_err(|_| anyhow!("Failed to spend spendable outputs"))?;
878879

mutiny-core/src/keymanager.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use bitcoin::secp256k1::ecdh::SharedSecret;
1212
use bitcoin::secp256k1::ecdsa::RecoverableSignature;
1313
use bitcoin::secp256k1::ecdsa::Signature;
1414
use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey, Signing};
15-
use bitcoin::{ScriptBuf, Transaction, TxOut};
15+
use bitcoin::{Address, ScriptBuf, Transaction, TxOut};
1616
use lightning::ln::msgs::{DecodeError, UnsignedGossipMessage};
1717
use lightning::ln::script::ShutdownScript;
1818
use lightning::offers::invoice::UnsignedBolt12Invoice;
@@ -68,8 +68,11 @@ impl<S: MutinyStorage> PhantomKeysManager<S> {
6868
feerate_sat_per_1000_weight: u32,
6969
locktime: Option<LockTime>,
7070
secp_ctx: &Secp256k1<C>,
71+
sweep_target_address: Option<Address>,
7172
) -> Result<Transaction, ()> {
72-
let address = {
73+
let address = if let Some(address) = sweep_target_address {
74+
address
75+
} else {
7376
let mut wallet = self.wallet.wallet.try_write().map_err(|_| ())?;
7477
// These often fail because we continually retry these. Use LastUnused so we don't generate a ton of new
7578
// addresses for no reason.

0 commit comments

Comments
 (0)