-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.go
29 lines (26 loc) · 1.01 KB
/
seed.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
package pfcharness
import (
"encoding/binary"
"github.com/jfixby/coinharness"
"github.com/picfight/pfcd/chaincfg/chainhash"
)
// hdSeed is the BIP 32 seed used by the InMemoryWallet to initialize it's
// HD root key. This value is hard coded in order to ensure
// deterministic behavior across test runs.
var hdSeed = [chainhash.HashSize]byte{
0x79, 0xa6, 0x1a, 0xdb, 0xc6, 0xe5, 0xa2, 0xe1,
0x39, 0xd2, 0x71, 0x3a, 0x54, 0x6e, 0xc7, 0xc8,
0x75, 0x63, 0x2e, 0x75, 0xf1, 0xdf, 0x9c, 0x3f,
0xa6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
// NewTestSeed generates new test wallet seed using predefined array hdSeed
// and a custom salt number
// The wallet's final HD seed is: [hdSeed || salt]. This method
// ensures that each harness instance uses a deterministic root seed
// based on its salt.
func NewTestSeed(salt uint32) /*[chainhash.HashSize + 4]byte*/ coinharness.Seed {
seed := [chainhash.HashSize + 4]byte{}
copy(seed[:], hdSeed[:])
binary.BigEndian.PutUint32(seed[:chainhash.HashSize], salt)
return seed[:]
}