keychain: use fast scrypt options for unit tests

This commit is contained in:
Oliver Gugger 2020-01-24 11:08:28 +01:00
parent 1cb52491a3
commit 29ece5fe24
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -11,6 +11,7 @@ import (
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcwallet/snacl"
"github.com/btcsuite/btcwallet/waddrmgr" "github.com/btcsuite/btcwallet/waddrmgr"
"github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wallet"
"github.com/btcsuite/btcwallet/walletdb" "github.com/btcsuite/btcwallet/walletdb"
@ -41,6 +42,19 @@ var (
) )
func createTestBtcWallet(coinType uint32) (func(), *wallet.Wallet, error) { func createTestBtcWallet(coinType uint32) (func(), *wallet.Wallet, error) {
// Instruct waddrmgr to use the cranked down scrypt parameters when
// creating new wallet encryption keys.
fastScrypt := waddrmgr.FastScryptOptions
keyGen := func(passphrase *[]byte, config *waddrmgr.ScryptOptions) (
*snacl.SecretKey, error) {
return snacl.NewSecretKey(
passphrase, fastScrypt.N, fastScrypt.R, fastScrypt.P,
)
}
waddrmgr.SetSecretKeyGen(keyGen)
// Create a new test wallet that uses fast scrypt as KDF.
tempDir, err := ioutil.TempDir("", "keyring-lnwallet") tempDir, err := ioutil.TempDir("", "keyring-lnwallet")
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err