-
Notifications
You must be signed in to change notification settings - Fork 651
/
base_tx.go
53 lines (44 loc) · 981 Bytes
/
base_tx.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package txs
import (
"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/vms/components/avax"
)
var _ UnsignedTx = &BaseTx{}
// BaseTx is the basis of all transactions.
type BaseTx struct {
avax.BaseTx `serialize:"true"`
}
func (t *BaseTx) InitCtx(ctx *snow.Context) {
for _, out := range t.Outs {
out.InitCtx(ctx)
}
}
func (t *BaseTx) SyntacticVerify(
ctx *snow.Context,
c codec.Manager,
txFeeAssetID ids.ID,
txFee uint64,
_ uint64,
_ int,
) error {
if t == nil {
return errNilTx
}
if err := t.MetadataVerify(ctx); err != nil {
return err
}
return avax.VerifyTx(
txFee,
txFeeAssetID,
[][]*avax.TransferableInput{t.Ins},
[][]*avax.TransferableOutput{t.Outs},
c,
)
}
func (t *BaseTx) Visit(v Visitor) error {
return v.BaseTx(t)
}