Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use log::debug;
use crate::{
bulletin_board::BulletinBoardId,
message::{MessageId, PayjoinProposal},
transaction::Outpoint,
wallet::{PaymentObligationData, PaymentObligationId, WalletHandleMut, WalletId},
Simulation, TimeStep,
};
Expand Down Expand Up @@ -329,6 +330,9 @@ fn simulate_one_action(wallet_handle: &WalletHandleMut, action: &Action) -> Vec<
/// TODO: Strategies should be composible. They should enform the action decision space scoring and doing actions should be handling by something else that has composed multiple strategies.
pub(crate) trait Strategy: std::fmt::Debug {
fn enumerate_candidate_actions(&self, state: &WalletView) -> Vec<Action>;
fn locked_inputs(&self, _state: &WalletView) -> Vec<Outpoint> {
vec![]
}
fn clone_box(&self) -> Box<dyn Strategy>;
}

Expand Down Expand Up @@ -538,6 +542,13 @@ impl Strategy for CompositeStrategy {
actions
}

fn locked_inputs(&self, state: &WalletView) -> Vec<Outpoint> {
self.strategies
.iter()
.flat_map(|s| s.locked_inputs(state))
.collect()
}

fn clone_box(&self) -> Box<dyn Strategy> {
Box::new(self.clone())
}
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,11 @@ mod tests {
.with_mut(&mut sim)
.new_tx(|tx, sim| {
// TODO use select_coins
let (inputs, drain) = alice.with(&sim).select_coins(target, long_term_feerate);
let locked = OrdSet::new();
let (inputs, drain) =
alice
.with(&sim)
.select_coins(target, long_term_feerate, &locked);

tx.inputs = inputs
.map(|o| Input {
Expand Down
Loading