-
Notifications
You must be signed in to change notification settings - Fork 646
/
base_tx.go
50 lines (40 loc) · 1 KB
/
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
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package txs
import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
)
var (
_ UnsignedTx = (*BaseTx)(nil)
_ secp256k1fx.UnsignedTx = (*BaseTx)(nil)
)
// BaseTx is the basis of all transactions.
type BaseTx struct {
avax.BaseTx `serialize:"true"`
bytes []byte
}
func (t *BaseTx) InitCtx(ctx *snow.Context) {
for _, out := range t.Outs {
out.InitCtx(ctx)
}
}
func (t *BaseTx) SetBytes(bytes []byte) {
t.bytes = bytes
}
func (t *BaseTx) Bytes() []byte {
return t.bytes
}
func (t *BaseTx) InputIDs() set.Set[ids.ID] {
inputIDs := set.NewSet[ids.ID](len(t.Ins))
for _, in := range t.Ins {
inputIDs.Add(in.InputID())
}
return inputIDs
}
func (t *BaseTx) Visit(v Visitor) error {
return v.BaseTx(t)
}