forked from decred/dcrwallet
-
Notifications
You must be signed in to change notification settings - Fork 2
/
helpers.go
29 lines (25 loc) · 936 Bytes
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (c) 2016 The btcsuite developers
// Copyright (c) 2016 The Decred 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/hybridnetwork/hxd/wire"
dcrutil "github.com/hybridnetwork/hxutil"
)
// SumOutputValues sums up the list of TxOuts and returns an Amount.
func SumOutputValues(outputs []*wire.TxOut) (totalOutput dcrutil.Amount) {
for _, txOut := range outputs {
totalOutput += dcrutil.Amount(txOut.Value)
}
return totalOutput
}
// SumOutputSerializeSizes sums up the serialized size of the supplied outputs.
func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int) {
for _, txOut := range outputs {
serializeSize += txOut.SerializeSize()
}
return serializeSize
}