-
Notifications
You must be signed in to change notification settings - Fork 655
/
import_tx.go
54 lines (44 loc) · 1.38 KB
/
import_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
54
// 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/utils/set"
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
)
var (
_ UnsignedTx = (*ImportTx)(nil)
_ secp256k1fx.UnsignedTx = (*ImportTx)(nil)
)
// ImportTx is a transaction that imports an asset from another blockchain.
type ImportTx struct {
BaseTx `serialize:"true"`
// Which chain to consume the funds from
SourceChain ids.ID `serialize:"true" json:"sourceChain"`
// The inputs to this transaction
ImportedIns []*avax.TransferableInput `serialize:"true" json:"importedInputs"`
}
// InputUTXOs track which UTXOs this transaction is consuming.
func (t *ImportTx) InputUTXOs() []*avax.UTXOID {
utxos := t.BaseTx.InputUTXOs()
for _, in := range t.ImportedIns {
in.Symbol = true
utxos = append(utxos, &in.UTXOID)
}
return utxos
}
func (t *ImportTx) InputIDs() set.Set[ids.ID] {
inputs := t.BaseTx.InputIDs()
for _, in := range t.ImportedIns {
inputs.Add(in.InputID())
}
return inputs
}
// NumCredentials returns the number of expected credentials
func (t *ImportTx) NumCredentials() int {
return t.BaseTx.NumCredentials() + len(t.ImportedIns)
}
func (t *ImportTx) Visit(v Visitor) error {
return v.ImportTx(t)
}