address: make Prefix overridable
As it should be, it's specified in the configuration file (and it should be treated as byte in the config)
This commit is contained in:
parent
e685e9bf9a
commit
89b6cbf795
3 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue