"math"
"time"
+ "github.com/vapor/common/arithmetic"
"github.com/vapor/errors"
"github.com/vapor/protocol/bc/types"
)
// AddOutput add outputs of transactions
func (b *TemplateBuilder) AddOutput(o *types.TxOutput) error {
- if o.Amount > math.MaxInt64 {
- return errors.WithDetailf(ErrBadAmount, "amount %d exceeds maximum value 2^63", o.Amount)
+ if o.AssetAmount().Amount > math.MaxInt64 {
+ return errors.WithDetailf(ErrBadAmount, "amount %d exceeds maximum value 2^63", o.AssetAmount().Amount)
}
b.outputs = append(b.outputs, o)
return nil
tx.Inputs = append(tx.Inputs, in)
}
+ var err error
tpl.Transaction = types.NewTx(*tx)
- tpl.Fee = CalculateTxFee(tpl.Transaction)
+ if tpl.Fee, err = arithmetic.CalculateTxFee(tpl.Transaction); err != nil {
+ return nil, nil, err
+ }
return tpl, tx, nil
}