add enable-0x-prefix flag (#194)

This commit is contained in:
Daniel Liu 2022-12-09 19:15:13 +08:00 committed by GitHub
parent f57e2c3577
commit 6a768b04f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View file

@ -165,6 +165,10 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
common.TIPXDCXCancellationFee = common.TIPXDCXCancellationFeeTestnet
}
if ctx.GlobalBool(utils.Enable0xPrefixFlag.Name) {
common.Enable0xPrefix = true;
}
// Rewound
if rewound := ctx.GlobalInt(utils.RewoundFlag.Name); rewound != 0 {
common.Rewound = uint64(rewound)

View file

@ -113,6 +113,7 @@ var (
//utils.RinkebyFlag,
//utils.VMEnableDebugFlag,
utils.XDCTestnetFlag,
utils.Enable0xPrefixFlag,
utils.RewoundFlag,
utils.NetworkIdFlag,
utils.RPCCORSDomainFlag,

View file

@ -115,6 +115,10 @@ var (
Usage: "Rollback chain at hash",
Value: "",
}
Enable0xPrefixFlag = cli.BoolFlag{
Name: "enable-0x-prefix",
Usage: "Addres use 0x-prefix (default = false)",
}
// General settings
AnnounceTxsFlag = cli.BoolFlag{
Name: "announce-txs",

View file

@ -45,6 +45,7 @@ var TIPXDCXCancellationFeeTestnet = big.NewInt(38383838)
var TIPXDCXTestnet = big.NewInt(38383838)
var IsTestnet bool = false
var Enable0xPrefix bool = false
var StoreRewardFolder string
var RollbackHash Hash
var BasePrice = big.NewInt(1000000000000000000) // 1

View file

@ -250,8 +250,11 @@ func (a *Address) Set(other Address) {
// MarshalText returns the hex representation of a.
func (a Address) MarshalText() ([]byte, error) {
// Handle '0x' or 'xdc' prefix here.
// return hexutil.Bytes(a[:]).MarshalText()
return hexutil.Bytes(a[:]).MarshalXDCText()
if (Enable0xPrefix) {
return hexutil.Bytes(a[:]).MarshalText()
} else {
return hexutil.Bytes(a[:]).MarshalXDCText()
}
}
// UnmarshalText parses a hash in hex syntax.