File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -97,11 +97,13 @@ impl CoinSelectorOpt {
9797 let mut tx = Transaction {
9898 input : vec ! [ ] ,
9999 version : 1 ,
100- lock_time : LockTime :: ZERO . into ( ) ,
100+ lock_time : absolute :: LockTime :: ZERO ,
101101 output : txouts. to_vec ( ) ,
102102 } ;
103103 let base_weight = tx. weight ( ) ;
104- // this awkward calculation is necessary since TxOut doesn't have \.weight()
104+ // Calculating drain_weight like this instead of using .weight()
105+ // allows us to take into account the output len varint increase that
106+ // might happen when adding a new output
105107 let drain_weight = {
106108 tx. output . push ( drain_output. clone ( ) ) ;
107109 tx. weight ( ) - base_weight
@@ -113,8 +115,8 @@ impl CoinSelectorOpt {
113115 Some ( txouts. iter ( ) . map ( |txout| txout. value ) . sum ( ) )
114116 } ,
115117 ..Self :: from_weights (
116- base_weight as u32 ,
117- drain_weight as u32 ,
118+ base_weight. to_wu ( ) as u32 ,
119+ drain_weight. to_wu ( ) as u32 ,
118120 TXIN_BASE_WEIGHT + drain_satisfaction_weight,
119121 )
120122 }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ use bdk_chain::{
1212 bitcoin,
1313 collections:: { BTreeSet , HashMap } ,
1414} ;
15- use bitcoin:: { LockTime , Transaction , TxOut } ;
15+ use bitcoin:: { absolute , Transaction , TxOut } ;
1616use core:: fmt:: { Debug , Display } ;
1717
1818mod coin_selector;
You can’t perform that action at this time.
0 commit comments