Skip to content

Commit

Permalink
Fix fee calculation for gettransaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Jan 29, 2016
1 parent 497ffc1 commit bb1102b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rpc/legacyrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,6 @@ func GetTransaction(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
var (
debitTotal btcutil.Amount
creditTotal btcutil.Amount // Excludes change
outputTotal btcutil.Amount
fee btcutil.Amount
feeF64 float64
)
Expand All @@ -869,11 +868,12 @@ func GetTransaction(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
creditTotal += cred.Amount
}
}
for _, output := range details.MsgTx.TxOut {
outputTotal -= btcutil.Amount(output.Value)
}
// Fee can only be determined if every input is a debit.
if len(details.Debits) == len(details.MsgTx.TxIn) {
var outputTotal btcutil.Amount
for _, output := range details.MsgTx.TxOut {
outputTotal += btcutil.Amount(output.Value)
}
fee = debitTotal - outputTotal
feeF64 = fee.ToBTC()
}
Expand Down

0 comments on commit bb1102b

Please sign in to comment.