Fix: addresses being derived from change branch instead of receive
This commit is contained in:
parent
50db541857
commit
05ca2c2c55
@ -33,18 +33,29 @@ if (xpub === 'xpub6DBMpym6PM3qe7Ug7BwG6zo7dinMMjpk8nmb73czsjkzPTzfQ1d5ZvqDea4uNm
|
||||
throw new Error('Example xpub must not be used! Repalce with your own account xpub.');
|
||||
|
||||
const acct = HDPublicKey.fromBase58(xpub);
|
||||
|
||||
// For some reason when bpkg'ed with -browser modules, we need to call
|
||||
// this once as a throwaway before actually using it.
|
||||
// The first function call FAILS because entropy can not be found to
|
||||
// "pregenerate a random blinding value" as part of the ECDSA precomputation.
|
||||
// For whatever reason, the function call succeeds from here on.
|
||||
// This is either a bug in bcrypto or bpkg, exposing an inconguity
|
||||
// with the -browser module.
|
||||
// See https://github.com/handshake-org/hsd/issues/700
|
||||
acct.derive(0);
|
||||
|
||||
const recv = acct.derive(0);
|
||||
|
||||
function addr() {
|
||||
const indexFile = path.join(__dirname, '..', 'log', 'hip2-index');
|
||||
let index = 0;
|
||||
try {
|
||||
index = parseInt(fs.readFileSync(indexFile));
|
||||
index = parseInt(fs.readFileSync(indexFile, 'utf-8'));
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
|
||||
fs.writeFileSync(indexFile, index + 1);
|
||||
fs.writeFileSync(indexFile, String(index + 1), 'utf-8');
|
||||
|
||||
// Wow, used all our non-hardened addresses!
|
||||
// Don't roll over the saved index (that way the user knows this has happened)
|
||||
|
@ -25,18 +25,29 @@ if (xpub === 'xpub6DBMpym6PM3qe7Ug7BwG6zo7dinMMjpk8nmb73czsjkzPTzfQ1d5ZvqDea4uNm
|
||||
throw new Error('Example xpub must not be used! Repalce with your own account xpub.');
|
||||
|
||||
const acct = HDPublicKey.fromBase58(xpub);
|
||||
|
||||
// For some reason when bpkg'ed with -browser modules, we need to call
|
||||
// this once as a throwaway before actually using it.
|
||||
// The first function call FAILS because entropy can not be found to
|
||||
// "pregenerate a random blinding value" as part of the ECDSA precomputation.
|
||||
// For whatever reason, the function call succeeds from here on.
|
||||
// This is either a bug in bcrypto or bpkg, exposing an inconguity
|
||||
// with the -browser module.
|
||||
// See https://github.com/handshake-org/hsd/issues/700
|
||||
acct.derive(0);
|
||||
|
||||
const recv = acct.derive(0);
|
||||
|
||||
function addr() {
|
||||
const indexFile = path.join(__dirname, '..', 'log', 'hip2-index');
|
||||
let index = 0;
|
||||
try {
|
||||
index = parseInt(fs.readFileSync(indexFile));
|
||||
index = parseInt(fs.readFileSync(indexFile, 'utf-8'));
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
|
||||
fs.writeFileSync(indexFile, index + 1);
|
||||
fs.writeFileSync(indexFile, String(index + 1), 'utf-8');
|
||||
|
||||
// Wow, used all our non-hardened addresses!
|
||||
// Don't roll over the saved index (that way the user knows this has happened)
|
||||
|
Loading…
Reference in New Issue
Block a user