18 lines
735 B
JavaScript
18 lines
735 B
JavaScript
|
|
import { DGB_COIN_TYPE } from './network.js';
|
||
|
|
// Convenience helper: full derivation-path string for a specific
|
||
|
|
// address, e.g. m/84'/20'/0'/0/5.
|
||
|
|
export function derivationPath(purpose, account, change, index) {
|
||
|
|
return `m/${purpose}'/${DGB_COIN_TYPE}'/${account}'/${change}/${index}`;
|
||
|
|
}
|
||
|
|
// xpub for an account, ready to be shared with a watch-only or
|
||
|
|
// external indexer. Never share the corresponding xprv.
|
||
|
|
export function accountXpub(accountNode) {
|
||
|
|
return accountNode.neutered().toBase58();
|
||
|
|
}
|
||
|
|
export function accountXprv(accountNode) {
|
||
|
|
if (!accountNode.privateKey) {
|
||
|
|
throw new Error('Node has no private key; cannot export xprv');
|
||
|
|
}
|
||
|
|
return accountNode.toBase58();
|
||
|
|
}
|
||
|
|
//# sourceMappingURL=descriptor.js.map
|