helpers.go raw
1 // Package helpers provides convenience functions to simplify wallet code. This package is intended for internal wallet
2 // use only.
3 package helpers
4
5 import (
6 "github.com/p9c/p9/pkg/amt"
7 "github.com/p9c/p9/pkg/wire"
8 )
9
10 // SumOutputValues sums up the list of TxOuts and returns an Amount.
11 func SumOutputValues(outputs []*wire.TxOut) (totalOutput amt.Amount) {
12 for _, txOut := range outputs {
13 totalOutput += amt.Amount(txOut.Value)
14 }
15 return totalOutput
16 }
17
18 // SumOutputSerializeSizes sums up the serialized size of the supplied outputs.
19 func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int) {
20 for _, txOut := range outputs {
21 serializeSize += txOut.SerializeSize()
22 }
23 return serializeSize
24 }
25