File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -2385,9 +2385,16 @@ impl Wallet {
2385
2385
& self . chain
2386
2386
}
2387
2387
2388
- /// List locked outpoints.
2389
- pub fn list_locked_outpoints ( & self ) -> impl Iterator < Item = UtxoLock > + ' _ {
2390
- self . locked_outpoints . values ( ) . copied ( )
2388
+ /// Get a reference to the locked outpoints.
2389
+ pub fn locked_outpoints ( & self ) -> & BTreeMap < OutPoint , UtxoLock > {
2390
+ & self . locked_outpoints
2391
+ }
2392
+
2393
+ /// List unspent outpoints that are currently locked.
2394
+ pub fn list_locked_unspent ( & self ) -> impl Iterator < Item = OutPoint > + ' _ {
2395
+ self . list_unspent ( )
2396
+ . filter ( |output| self . is_outpoint_locked ( output. outpoint ) )
2397
+ . map ( |output| output. outpoint )
2391
2398
}
2392
2399
2393
2400
/// Whether the `outpoint` is currently locked. See [`Wallet::lock_outpoint`] for more.
Original file line number Diff line number Diff line change @@ -64,8 +64,10 @@ fn test_lock_outpoint_persist() -> anyhow::Result<()> {
64
64
. create_wallet ( & mut conn) ?;
65
65
66
66
// Receive coins.
67
+ let mut outpoints = vec ! [ ] ;
67
68
for i in 0 ..3 {
68
- let _ = receive_output ( & mut wallet, Amount :: from_sat ( 10_000 ) , ReceiveTo :: Mempool ( i) ) ;
69
+ let op = receive_output ( & mut wallet, Amount :: from_sat ( 10_000 ) , ReceiveTo :: Mempool ( i) ) ;
70
+ outpoints. push ( op) ;
69
71
}
70
72
71
73
// Test: lock outpoints
@@ -94,7 +96,8 @@ fn test_lock_outpoint_persist() -> anyhow::Result<()> {
94
96
"Expect recover lock value"
95
97
) ;
96
98
}
97
- assert ! ( wallet. list_locked_outpoints( ) . all( |u| u. is_locked) ) ;
99
+ let locked_unspent = wallet. list_locked_unspent ( ) . collect :: < Vec < _ > > ( ) ;
100
+ assert_eq ! ( locked_unspent, outpoints) ;
98
101
99
102
// Test: Locked outpoints are excluded from coin selection
100
103
let addr = wallet. next_unused_address ( KeychainKind :: External ) . address ;
@@ -127,7 +130,8 @@ fn test_lock_outpoint_persist() -> anyhow::Result<()> {
127
130
"Expect outpoint is not locked"
128
131
) ;
129
132
}
130
- assert ! ( !wallet. list_locked_outpoints( ) . any( |u| u. is_locked) ) ;
133
+ assert ! ( !wallet. locked_outpoints( ) . values( ) . any( |u| u. is_locked) ) ;
134
+ assert ! ( wallet. list_locked_unspent( ) . next( ) . is_none( ) ) ;
131
135
wallet. persist ( & mut conn) ?;
132
136
133
137
// Test: Update lock expiry
You can’t perform that action at this time.
0 commit comments