-
Notifications
You must be signed in to change notification settings - Fork 114
/
address.go
40 lines (32 loc) · 1.04 KB
/
address.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
package address
import (
"github.com/iotaledger/hive.go/core/stringify"
"github.com/mr-tron/base58"
"github.com/iotaledger/goshimmer/packages/core/ledger/vm/devnetvm"
)
// Address represents an address in a wallet. It extends the normal address type with an index number that was used to
// generate the address from its seed.
type Address struct {
AddressBytes [devnetvm.AddressLength]byte
Index uint64
}
// Address returns the ledgerstate Address of this wallet Address.
func (a Address) Address() (ledgerStateAddress devnetvm.Address) {
ledgerStateAddress, _, err := devnetvm.AddressFromBytes(a.AddressBytes[:])
if err != nil {
panic(err)
}
return
}
// Base58 returns the base58 encoded address.
func (a Address) Base58() string {
return base58.Encode(a.AddressBytes[:])
}
func (a Address) String() string {
return stringify.Struct("Address",
stringify.NewStructField("Address", a.Address()),
stringify.NewStructField("Index", a.Index),
)
}
// AddressEmpty represents the 0-value of an address.
var AddressEmpty = Address{}