@@ -60,6 +60,7 @@ pub struct BuilderIterator<'a> {
60
60
force : bool ,
61
61
median_time : u64 ,
62
62
confirmed_only : bool ,
63
+ unspendables : Vec < OutPoint >
63
64
}
64
65
65
66
pub enum BuilderStack {
@@ -324,6 +325,7 @@ impl Builder {
324
325
reveals : Option < & Vec < SpaceScriptSigningInfo > > ,
325
326
space_transfers : Vec < SpaceTransfer > ,
326
327
coin_transfers : Vec < CoinTransfer > ,
328
+ unspendables : Vec < OutPoint > ,
327
329
fee_rate : FeeRate ,
328
330
dust : Option < Amount > ,
329
331
confirmed_only : bool ,
@@ -359,7 +361,7 @@ impl Builder {
359
361
}
360
362
361
363
let commit_psbt = {
362
- let mut builder = w. build_tx ( confirmed_only) ?;
364
+ let mut builder = w. build_tx ( unspendables , confirmed_only) ?;
363
365
builder. nlocktime ( magic_lock_time ( median_time) ) ;
364
366
365
367
// handle transfers
@@ -478,9 +480,11 @@ impl Iterator for BuilderIterator<'_> {
478
480
Some ( & reveals) ,
479
481
params. transfers . clone ( ) ,
480
482
params. sends . clone ( ) ,
483
+ self . unspendables . clone ( ) ,
481
484
self . fee_rate ,
482
485
self . dust ,
483
486
self . confirmed_only ,
487
+
484
488
) {
485
489
Ok ( prep) => prep,
486
490
Err ( err) => return Some ( Err ( err) ) ,
@@ -571,6 +575,7 @@ impl Iterator for BuilderIterator<'_> {
571
575
self . wallet ,
572
576
params. clone ( ) ,
573
577
self . fee_rate ,
578
+ self . unspendables . clone ( ) ,
574
579
self . confirmed_only ,
575
580
self . force ,
576
581
) ;
@@ -586,6 +591,7 @@ impl Iterator for BuilderIterator<'_> {
586
591
self . wallet ,
587
592
params,
588
593
self . fee_rate ,
594
+ self . unspendables . clone ( ) ,
589
595
self . confirmed_only ,
590
596
self . force ,
591
597
) ;
@@ -607,6 +613,7 @@ impl Iterator for BuilderIterator<'_> {
607
613
bid. space . clone ( ) ,
608
614
bid. amount ,
609
615
self . fee_rate ,
616
+ self . unspendables . clone ( ) ,
610
617
self . confirmed_only ,
611
618
self . force ,
612
619
) ;
@@ -692,6 +699,7 @@ impl Builder {
692
699
dust : Option < Amount > ,
693
700
median_time : u64 ,
694
701
wallet : & mut SpacesWallet ,
702
+ unspendables : Vec < OutPoint > ,
695
703
confirmed_only : bool ,
696
704
) -> anyhow:: Result < BuilderIterator > {
697
705
let fee_rate = self
@@ -799,6 +807,7 @@ impl Builder {
799
807
fee_rate,
800
808
wallet,
801
809
force : self . force ,
810
+ unspendables,
802
811
confirmed_only,
803
812
median_time,
804
813
} )
@@ -809,12 +818,13 @@ impl Builder {
809
818
prev : FullSpaceOut ,
810
819
bid : Amount ,
811
820
fee_rate : FeeRate ,
821
+ unspendables : Vec < OutPoint > ,
812
822
confirmed_only : bool ,
813
823
force : bool ,
814
824
) -> anyhow:: Result < Transaction > {
815
825
let ( offer, placeholder) = w. new_bid_psbt ( bid, confirmed_only) ?;
816
826
let bid_psbt = {
817
- let mut builder = w. build_tx ( confirmed_only) ?;
827
+ let mut builder = w. build_tx ( unspendables , confirmed_only) ?;
818
828
builder
819
829
. nlocktime ( LockTime :: Blocks ( Height :: ZERO ) )
820
830
. set_exact_sequence ( BID_PSBT_INPUT_SEQUENCE )
@@ -838,13 +848,14 @@ impl Builder {
838
848
w : & mut SpacesWallet ,
839
849
params : OpenRevealParams ,
840
850
fee_rate : FeeRate ,
851
+ unspendables : Vec < OutPoint > ,
841
852
confirmed_only : bool ,
842
853
force : bool ,
843
854
) -> anyhow:: Result < Transaction > {
844
855
let ( offer, placeholder) = w. new_bid_psbt ( params. initial_bid , confirmed_only) ?;
845
856
let mut extra_prevouts = BTreeMap :: new ( ) ;
846
857
let open_psbt = {
847
- let mut builder = w. build_tx ( confirmed_only) ?;
858
+ let mut builder = w. build_tx ( unspendables , confirmed_only) ?;
848
859
builder. ordering ( TxOrdering :: Untouched ) . add_bid (
849
860
None ,
850
861
offer,
@@ -871,6 +882,7 @@ impl Builder {
871
882
w : & mut SpacesWallet ,
872
883
params : ExecuteParams ,
873
884
fee_rate : FeeRate ,
885
+ unspendables : Vec < OutPoint > ,
874
886
confirmed_only : bool ,
875
887
_force : bool ,
876
888
) -> anyhow:: Result < ( Transaction , usize ) > {
@@ -881,7 +893,7 @@ impl Builder {
881
893
. internal
882
894
. next_unused_address ( KeychainKind :: Internal )
883
895
. script_pubkey ( ) ;
884
- let mut builder = w. build_tx ( confirmed_only) ?;
896
+ let mut builder = w. build_tx ( unspendables , confirmed_only) ?;
885
897
886
898
builder
887
899
// Added first to keep an odd number of outputs before adding transfers
@@ -935,7 +947,7 @@ pub struct SelectionOutput {
935
947
pub struct SpacesAwareCoinSelection {
936
948
pub default_algorithm : DefaultCoinSelectionAlgorithm ,
937
949
// Exclude outputs
938
- pub exclude_outputs : Vec < SelectionOutput > ,
950
+ pub exclude_outputs : Vec < OutPoint > ,
939
951
// Whether to use confirmed only outputs
940
952
// to fund the transaction
941
953
pub confirmed_only : bool ,
@@ -945,7 +957,7 @@ impl SpacesAwareCoinSelection {
945
957
// Will skip any outputs with value less than the dust threshold
946
958
// to avoid accidentally spending space outputs
947
959
pub const DUST_THRESHOLD : Amount = Amount :: from_sat ( 1200 ) ;
948
- pub fn new ( excluded : Vec < SelectionOutput > , confirmed_only : bool ) -> Self {
960
+ pub fn new ( excluded : Vec < OutPoint > , confirmed_only : bool ) -> Self {
949
961
Self {
950
962
default_algorithm : DefaultCoinSelectionAlgorithm :: default ( ) ,
951
963
exclude_outputs : excluded,
@@ -986,7 +998,7 @@ impl CoinSelectionAlgorithm for SpacesAwareCoinSelection {
986
998
&& !self
987
999
. exclude_outputs
988
1000
. iter ( )
989
- . any ( |o| o. outpoint == weighted_utxo. utxo . outpoint ( ) )
1001
+ . any ( |o| o == & weighted_utxo. utxo . outpoint ( ) )
990
1002
} ) ;
991
1003
992
1004
let mut result = self . default_algorithm . coin_select (
0 commit comments