mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
Changed HD wallet path from 60 to 108
This commit is contained in:
parent
440b5a2242
commit
9c753ed0c3
2 changed files with 33 additions and 33 deletions
|
|
@ -25,17 +25,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultRootDerivationPath is the root path to which custom derivation endpoints
|
// DefaultRootDerivationPath is the root path to which custom derivation endpoints
|
||||||
// are appended. As such, the first account will be at m/44'/60'/0'/0, the second
|
// are appended. As such, the first account will be at m/44'/108'/0'/0, the second
|
||||||
// at m/44'/60'/0'/1, etc.
|
// at m/44'/108'/0'/1, etc.
|
||||||
var DefaultRootDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0}
|
var DefaultRootDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0}
|
||||||
|
|
||||||
// DefaultBaseDerivationPath is the base path from which custom derivation endpoints
|
// DefaultBaseDerivationPath is the base path from which custom derivation endpoints
|
||||||
// are incremented. As such, the first account will be at m/44'/60'/0'/0, the second
|
// are incremented. As such, the first account will be at m/44'/108'/0'/0, the second
|
||||||
// at m/44'/60'/0'/1, etc.
|
// at m/44'/108'/0'/1, etc.
|
||||||
var DefaultBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}
|
var DefaultBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0}
|
||||||
|
|
||||||
// DerivationPath represents the computer friendly version of a hierarchical
|
// DerivationPath represents the computer friendly version of a hierarchical
|
||||||
// deterministic wallet account derivaion path.
|
// deterministic wallet account derivation path.
|
||||||
//
|
//
|
||||||
// The BIP-32 spec https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
|
// The BIP-32 spec https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
|
||||||
// defines derivation paths to be of the form:
|
// defines derivation paths to be of the form:
|
||||||
|
|
@ -45,9 +45,9 @@ var DefaultBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60,
|
||||||
// The BIP-44 spec https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
|
// The BIP-44 spec https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
|
||||||
// defines that the `purpose` be 44' (or 0x8000002C) for crypto currencies, and
|
// defines that the `purpose` be 44' (or 0x8000002C) for crypto currencies, and
|
||||||
// SLIP-44 https://github.com/satoshilabs/slips/blob/master/slip-0044.md assigns
|
// SLIP-44 https://github.com/satoshilabs/slips/blob/master/slip-0044.md assigns
|
||||||
// the `coin_type` 60' (or 0x8000003C) to Ethereum.
|
// the `coin_type` 108' (or 0x8000006C) to Gubiq.
|
||||||
//
|
//
|
||||||
// The root path for Ethereum is m/44'/60'/0'/0 according to the specification
|
// The root path for Gubiq is m/44'/108'/0'/0 according to the specification
|
||||||
// from https://github.com/ethereum/EIPs/issues/84, albeit it's not set in stone
|
// from https://github.com/ethereum/EIPs/issues/84, albeit it's not set in stone
|
||||||
// yet whether accounts should increment the last component or the children of
|
// yet whether accounts should increment the last component or the children of
|
||||||
// that. We will go with the simpler approach of incrementing the last component.
|
// that. We will go with the simpler approach of incrementing the last component.
|
||||||
|
|
|
||||||
|
|
@ -29,43 +29,43 @@ func TestHDPathParsing(t *testing.T) {
|
||||||
output DerivationPath
|
output DerivationPath
|
||||||
}{
|
}{
|
||||||
// Plain absolute derivation paths
|
// Plain absolute derivation paths
|
||||||
{"m/44'/60'/0'/0", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}},
|
{"m/44'/108'/0'/0", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0}},
|
||||||
{"m/44'/60'/0'/128", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 128}},
|
{"m/44'/108'/0'/128", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 128}},
|
||||||
{"m/44'/60'/0'/0'", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 0}},
|
{"m/44'/108'/0'/0'", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 0}},
|
||||||
{"m/44'/60'/0'/128'", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 128}},
|
{"m/44'/108'/0'/128'", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 128}},
|
||||||
{"m/2147483692/2147483708/2147483648/0", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}},
|
{"m/2147483692/2147483756/2147483648/0", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0}},
|
||||||
{"m/2147483692/2147483708/2147483648/2147483648", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 0}},
|
{"m/2147483692/2147483756/2147483648/2147483648", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 0}},
|
||||||
|
|
||||||
// Plain relative derivation paths
|
// Plain relative derivation paths
|
||||||
{"0", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}},
|
{"0", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0}},
|
||||||
{"128", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 128}},
|
{"128", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 128}},
|
||||||
{"0'", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 0}},
|
{"0'", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 0}},
|
||||||
{"128'", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 128}},
|
{"128'", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 128}},
|
||||||
{"2147483648", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 0}},
|
{"2147483648", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 0}},
|
||||||
|
|
||||||
// Hexadecimal absolute derivation paths
|
// Hexadecimal absolute derivation paths
|
||||||
{"m/0x2C'/0x3c'/0x00'/0x00", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}},
|
{"m/0x2C'/0x3c'/0x00'/0x00", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0}},
|
||||||
{"m/0x2C'/0x3c'/0x00'/0x80", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 128}},
|
{"m/0x2C'/0x3c'/0x00'/0x80", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 128}},
|
||||||
{"m/0x2C'/0x3c'/0x00'/0x00'", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 0}},
|
{"m/0x2C'/0x3c'/0x00'/0x00'", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 0}},
|
||||||
{"m/0x2C'/0x3c'/0x00'/0x80'", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 128}},
|
{"m/0x2C'/0x3c'/0x00'/0x80'", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 128}},
|
||||||
{"m/0x8000002C/0x8000003c/0x80000000/0x00", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}},
|
{"m/0x8000002C/0x8000006c/0x80000000/0x00", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0}},
|
||||||
{"m/0x8000002C/0x8000003c/0x80000000/0x80000000", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 0}},
|
{"m/0x8000002C/0x8000006c/0x80000000/0x80000000", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 0}},
|
||||||
|
|
||||||
// Hexadecimal relative derivation paths
|
// Hexadecimal relative derivation paths
|
||||||
{"0x00", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}},
|
{"0x00", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0}},
|
||||||
{"0x80", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 128}},
|
{"0x80", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 128}},
|
||||||
{"0x00'", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 0}},
|
{"0x00'", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 0}},
|
||||||
{"0x80'", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 128}},
|
{"0x80'", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 128}},
|
||||||
{"0x80000000", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0x80000000 + 0}},
|
{"0x80000000", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0x80000000 + 0}},
|
||||||
|
|
||||||
// Weird inputs just to ensure they work
|
// Weird inputs just to ensure they work
|
||||||
{" m / 44 '\n/\n 60 \n\n\t' /\n0 ' /\t\t 0", DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}},
|
{" m / 44 '\n/\n 108 \n\n\t' /\n0 ' /\t\t 0", DerivationPath{0x80000000 + 44, 0x80000000 + 108, 0x80000000 + 0, 0}},
|
||||||
|
|
||||||
// Invaid derivation paths
|
// Invaid derivation paths
|
||||||
{"", nil}, // Empty relative derivation path
|
{"", nil}, // Empty relative derivation path
|
||||||
{"m", nil}, // Empty absolute derivation path
|
{"m", nil}, // Empty absolute derivation path
|
||||||
{"m/", nil}, // Missing last derivation component
|
{"m/", nil}, // Missing last derivation component
|
||||||
{"/44'/60'/0'/0", nil}, // Absolute path without m prefix, might be user error
|
{"/44'/108'/0'/0", nil}, // Absolute path without m prefix, might be user error
|
||||||
{"m/2147483648'", nil}, // Overflows 32 bit integer
|
{"m/2147483648'", nil}, // Overflows 32 bit integer
|
||||||
{"m/-1'", nil}, // Cannot contain negative number
|
{"m/-1'", nil}, // Cannot contain negative number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue