diff --git a/cli/server/server.go b/cli/server/server.go index d742e0d1c..965e3fb2a 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -9,6 +9,7 @@ import ( "github.com/CityOfZion/neo-go/config" "github.com/CityOfZion/neo-go/pkg/core" "github.com/CityOfZion/neo-go/pkg/core/storage" + "github.com/CityOfZion/neo-go/pkg/encoding/address" "github.com/CityOfZion/neo-go/pkg/io" "github.com/CityOfZion/neo-go/pkg/network" "github.com/CityOfZion/neo-go/pkg/network/metrics" @@ -361,6 +362,9 @@ func initBlockChain(cfg config.Config) (*core.Blockchain, error) { if err != nil { return nil, cli.NewExitError(fmt.Errorf("could not initialize blockchain: %s", err), 1) } + if cfg.ProtocolConfiguration.AddressVersion != 0 { + address.Prefix = cfg.ProtocolConfiguration.AddressVersion + } return chain, nil } diff --git a/config/config.go b/config/config.go index cf86d9e32..f962ec41c 100644 --- a/config/config.go +++ b/config/config.go @@ -43,7 +43,7 @@ type ( // ProtocolConfiguration represents the protocol config. ProtocolConfiguration struct { Magic NetMode `yaml:"Magic"` - AddressVersion int64 `yaml:"AddressVersion"` + AddressVersion byte `yaml:"AddressVersion"` SecondsPerBlock int `yaml:"SecondsPerBlock"` LowPriorityThreshold float64 `yaml:"LowPriorityThreshold"` MaxTransactionsPerBlock int64 `yaml:"MaxTransactionsPerBlock"` diff --git a/pkg/encoding/address/address.go b/pkg/encoding/address/address.go index 34638494d..62e9404bc 100644 --- a/pkg/encoding/address/address.go +++ b/pkg/encoding/address/address.go @@ -5,10 +5,14 @@ import ( "github.com/CityOfZion/neo-go/pkg/util" ) +// Prefix is the byte used to prepend to addresses when encoding them, it can +// be changed and defaults to 23 (0x17), the standard NEO prefix. +var Prefix = byte(0x17) + // EncodeUint160 returns the "NEO address" from the given Uint160. func EncodeUint160(u util.Uint160) string { // Dont forget to prepend the Address version 0x17 (23) A - b := append([]byte{0x17}, u.BytesBE()...) + b := append([]byte{Prefix}, u.BytesBE()...) return base58.CheckEncode(b) }