@@ -1399,19 +1399,13 @@ impl Wallet {
13991399        } 
14001400
14011401        let  mut  outgoing = Amount :: ZERO ; 
1402-         let  mut  received = Amount :: ZERO ; 
1403- 
14041402        let  recipients = params. recipients . iter ( ) . map ( |( r,  v) | ( r,  * v) ) ; 
14051403
14061404        for  ( index,  ( script_pubkey,  value) )  in  recipients. enumerate ( )  { 
14071405            if  !params. allow_dust  && value. is_dust ( script_pubkey)  && !script_pubkey. is_op_return ( )  { 
14081406                return  Err ( CreateTxError :: OutputBelowDustLimit ( index) ) ; 
14091407            } 
14101408
1411-             if  self . is_mine ( script_pubkey. clone ( ) )  { 
1412-                 received += value; 
1413-             } 
1414- 
14151409            let  new_out = TxOut  { 
14161410                script_pubkey :  script_pubkey. clone ( ) , 
14171411                value, 
@@ -1467,9 +1461,8 @@ impl Wallet {
14671461                rng, 
14681462            ) 
14691463            . map_err ( CreateTxError :: CoinSelection ) ?; 
1470-         fee_amount += coin_selection. fee_amount ; 
1471-         let  excess = & coin_selection. excess ; 
14721464
1465+         let  excess = & coin_selection. excess ; 
14731466        tx. input  = coin_selection
14741467            . selected 
14751468            . iter ( ) 
@@ -1508,28 +1501,19 @@ impl Wallet {
15081501            } 
15091502        } 
15101503
1511-         match  excess { 
1512-             Excess :: NoChange  { 
1513-                 remaining_amount,  ..
1514-             }  => fee_amount += * remaining_amount, 
1515-             Excess :: Change  {  amount,  fee }  => { 
1516-                 if  self . is_mine ( drain_script. clone ( ) )  { 
1517-                     received += * amount; 
1518-                 } 
1519-                 fee_amount += * fee; 
1520- 
1521-                 // create drain output 
1522-                 let  drain_output = TxOut  { 
1523-                     value :  * amount, 
1524-                     script_pubkey :  drain_script, 
1525-                 } ; 
1504+         // if there's change, create and add a change output 
1505+         if  let  Excess :: Change  {  amount,  .. }  = excess { 
1506+             // create drain output 
1507+             let  drain_output = TxOut  { 
1508+                 value :  * amount, 
1509+                 script_pubkey :  drain_script, 
1510+             } ; 
15261511
1527-                 // TODO: We should pay attention when adding a new output: this might increase 
1528-                 // the length of the "number of vouts" parameter by 2 bytes, potentially making 
1529-                 // our feerate too low 
1530-                 tx. output . push ( drain_output) ; 
1531-             } 
1532-         } ; 
1512+             // TODO: We should pay attention when adding a new output: this might increase 
1513+             // the length of the "number of vouts" parameter by 2 bytes, potentially making 
1514+             // our feerate too low 
1515+             tx. output . push ( drain_output) ; 
1516+         } 
15331517
15341518        // sort input/outputs according to the chosen algorithm 
15351519        params. ordering . sort_tx_with_aux_rand ( & mut  tx,  rng) ; 
0 commit comments