-
Notifications
You must be signed in to change notification settings - Fork 43
/
helpers.go
30 lines (26 loc) · 965 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
30
// Copyright (c) 2016 The btcsuite developers
// Copyright (c) 2016 The Decred developers
// Copyright (c) 2018-2020 The Hc 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/HcashOrg/hcd/wire"
"github.com/HcashOrg/hcd/hcutil"
)
// SumOutputValues sums up the list of TxOuts and returns an Amount.
func SumOutputValues(outputs []*wire.TxOut) (totalOutput hcutil.Amount) {
for _, txOut := range outputs {
totalOutput += hcutil.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
}