@@ -1399,19 +1399,13 @@ impl Wallet {
1399
1399
}
1400
1400
1401
1401
let mut outgoing = Amount :: ZERO ;
1402
- let mut received = Amount :: ZERO ;
1403
-
1404
1402
let recipients = params. recipients . iter ( ) . map ( |( r, v) | ( r, * v) ) ;
1405
1403
1406
1404
for ( index, ( script_pubkey, value) ) in recipients. enumerate ( ) {
1407
1405
if !params. allow_dust && value. is_dust ( script_pubkey) && !script_pubkey. is_op_return ( ) {
1408
1406
return Err ( CreateTxError :: OutputBelowDustLimit ( index) ) ;
1409
1407
}
1410
1408
1411
- if self . is_mine ( script_pubkey. clone ( ) ) {
1412
- received += value;
1413
- }
1414
-
1415
1409
let new_out = TxOut {
1416
1410
script_pubkey : script_pubkey. clone ( ) ,
1417
1411
value,
@@ -1467,9 +1461,8 @@ impl Wallet {
1467
1461
rng,
1468
1462
)
1469
1463
. map_err ( CreateTxError :: CoinSelection ) ?;
1470
- fee_amount += coin_selection. fee_amount ;
1471
- let excess = & coin_selection. excess ;
1472
1464
1465
+ let excess = & coin_selection. excess ;
1473
1466
tx. input = coin_selection
1474
1467
. selected
1475
1468
. iter ( )
@@ -1508,28 +1501,19 @@ impl Wallet {
1508
1501
}
1509
1502
}
1510
1503
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
+ } ;
1526
1511
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
+ }
1533
1517
1534
1518
// sort input/outputs according to the chosen algorithm
1535
1519
params. ordering . sort_tx_with_aux_rand ( & mut tx, rng) ;
0 commit comments