aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-18 08:31:51 +0800
committerobscuren <geffobscura@gmail.com>2014-02-18 08:31:51 +0800
commitbb3e28310ee3c2cfc5b3153510d4a1d220a22e81 (patch)
tree7f95ff49afe89b494b28e2bbb8b516da2157b320
parenta5b7279cb507de93fde39d86c414e417f2d0b3e3 (diff)
downloaddexon-bb3e28310ee3c2cfc5b3153510d4a1d220a22e81.tar
dexon-bb3e28310ee3c2cfc5b3153510d4a1d220a22e81.tar.gz
dexon-bb3e28310ee3c2cfc5b3153510d4a1d220a22e81.tar.bz2
dexon-bb3e28310ee3c2cfc5b3153510d4a1d220a22e81.tar.lz
dexon-bb3e28310ee3c2cfc5b3153510d4a1d220a22e81.tar.xz
dexon-bb3e28310ee3c2cfc5b3153510d4a1d220a22e81.tar.zst
dexon-bb3e28310ee3c2cfc5b3153510d4a1d220a22e81.zip
If sender is receiver only subtract the fee
-rw-r--r--ethchain/transaction_pool.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go
index c2d65a2a7..75a8aa5d1 100644
--- a/ethchain/transaction_pool.go
+++ b/ethchain/transaction_pool.go
@@ -106,17 +106,25 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
}
}
- // Subtract the amount from the senders account
- sender.Amount.Sub(sender.Amount, totAmount)
- sender.Nonce += 1
-
// Get the receiver
receiver := block.GetAddr(tx.Recipient)
- // Add the amount to receivers account which should conclude this transaction
- receiver.Amount.Add(receiver.Amount, tx.Value)
+ sender.Nonce += 1
+
+ // Send Tx to self
+ if bytes.Compare(tx.Recipient, tx.Sender()) == 0 {
+ // Subtract the fee
+ sender.Amount.Sub(sender.Amount, new(big.Int).Mul(TxFee, TxFeeRat))
+ } else {
+ // Subtract the amount from the senders account
+ sender.Amount.Sub(sender.Amount, totAmount)
+
+ // Add the amount to receivers account which should conclude this transaction
+ receiver.Amount.Add(receiver.Amount, tx.Value)
+
+ block.UpdateAddr(tx.Recipient, receiver)
+ }
block.UpdateAddr(tx.Sender(), sender)
- block.UpdateAddr(tx.Recipient, receiver)
return
}