Skip to content

Commit

Permalink
loader: Tweak seed to be like dex.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGruffins committed Oct 28, 2024
1 parent 59c3bb9 commit c890cb2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion asset/dcr/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dcr

import (
"context"
"encoding/binary"
"fmt"
"os"
"path/filepath"
Expand All @@ -10,6 +11,7 @@ import (
"decred.org/dcrwallet/v4/wallet"
_ "decred.org/dcrwallet/v4/wallet/drivers/bdb"
"decred.org/dcrwallet/v4/wallet/udb"
"github.com/decred/dcrd/crypto/blake256"
"github.com/decred/dcrd/hdkeychain/v3"
"github.com/decred/libwallet/asset"
)
Expand Down Expand Up @@ -89,8 +91,14 @@ func CreateWallet(ctx context.Context, params asset.CreateWalletParams, recovery
}
}()

// Adjust seed to create the same wallet as dex.
b := make([]byte, len(seed)+4)
copy(b, seed)
binary.BigEndian.PutUint32(b[len(seed):], 42)
s := blake256.Sum256(b)

// Initialize the newly created database for the wallet before opening.
err = wallet.Create(ctx, db, nil, params.Pass, seed, chainParams)
err = wallet.Create(ctx, db, nil, params.Pass, s[:], chainParams)
if err != nil {
return nil, fmt.Errorf("wallet.Create error: %w", err)
}
Expand Down

0 comments on commit c890cb2

Please sign in to comment.