2016-02-28 05:30:56 +01:00
|
|
|
// Copyright (c) 2016 The btcsuite developers
|
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Package helpers provides convenience functions to simplify wallet code. This
|
|
|
|
// package is intended for internal wallet use only.
|
|
|
|
package helpers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
|
|
|
"github.com/btcsuite/btcutil"
|
|
|
|
)
|
|
|
|
|
2016-03-25 20:11:25 +01:00
|
|
|
// SumOutputValues sums up the list of TxOuts and returns an Amount.
|
2016-02-28 05:30:56 +01:00
|
|
|
func SumOutputValues(outputs []*wire.TxOut) (totalOutput btcutil.Amount) {
|
|
|
|
for _, txOut := range outputs {
|
|
|
|
totalOutput += btcutil.Amount(txOut.Value)
|
|
|
|
}
|
|
|
|
return totalOutput
|
|
|
|
}
|
|
|
|
|
2016-03-25 20:11:25 +01:00
|
|
|
// SumOutputSerializeSizes sums up the serialized size of the supplied outputs.
|
2016-02-28 05:30:56 +01:00
|
|
|
func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int) {
|
|
|
|
for _, txOut := range outputs {
|
|
|
|
serializeSize += txOut.SerializeSize()
|
|
|
|
}
|
|
|
|
return serializeSize
|
|
|
|
}
|