Reported as "the Aegis DigiByte import error". The vendored @dgb-wallet/core modules under lib/dgb/ imported "bitcoinjs-lib", "bip32", "ecpair", "bip39" and "@bitcoinerlab/secp256k1" as bare specifiers. Node's ESM resolver walks up from the importing file, so that resolves in a dev checkout — where Theseus's node_modules sits above the add-on — and resolves nowhere once Aegis is running from <userData>/extensions/aegis/, which is every OTA install. The import threw, index.js caught it and set dgbCore = null, and any DigiByte import then died in digibyteNetwork() with "DGB adapter not available". So DigiByte worked on a fresh install and disappeared after the first update. Confirmed on this machine: the only node_modules reachable from the installed extension carries bip39 and none of the other four. lib/dgb/deps.js now holds the dependencies, injected by index.js from api.require (which resolves against the app tree) before anything under lib/dgb/ is imported — the same pattern every other lib/*.js in Aegis already uses, and the reason that pattern exists. Consumers read them through accessors rather than capturing them at module scope, so import order is no longer load-bearing: hd.js builds its bip32 on first use and the two initEccLib callers go through a once-only ensureEcc(). Using a DGB module without injection now throws a named error instead of a resolver failure swallowed into a null. Verified by loading the modules from a directory with no reachable node_modules and deriving real addresses: BIP44 D…, BIP49 S… with its legacy 3… pair, BIP84 dgb1q…, BIP86 dgb1p… taproot, plus a WIF round-trip and the non-DGB WIF rejection.
51 lines
No EOL
2 KiB
JavaScript
51 lines
No EOL
2 KiB
JavaScript
import { payments, ensureEcc } from '../deps.js';
|
|
import { digibyte, digibyteLegacyP2SH } from './network.js';
|
|
export function p2pkhAddress(node, network = digibyte) {
|
|
const { address } = payments().p2pkh({
|
|
pubkey: Buffer.from(node.publicKey),
|
|
network,
|
|
});
|
|
if (!address)
|
|
throw new Error('p2pkh derivation returned no address');
|
|
return address;
|
|
}
|
|
export function p2shP2wpkhAddress(node, network = digibyte) {
|
|
const redeem = payments().p2wpkh({
|
|
pubkey: Buffer.from(node.publicKey),
|
|
network,
|
|
});
|
|
const { address } = payments().p2sh({ redeem, network });
|
|
if (!address)
|
|
throw new Error('p2sh-p2wpkh derivation returned no address');
|
|
return address;
|
|
}
|
|
// Derive the "S..." (current DGB, scriptHash 0x3f) AND "3..." (legacy
|
|
// Bitcoin-compatible, scriptHash 0x05) BIP49 addresses for the same
|
|
// key. Ian Coleman's BIP39 tool and several older wallets generate the
|
|
// legacy "3..." variant, so any seed-recovery scan must check both.
|
|
export function p2shP2wpkhAddressesBoth(node) {
|
|
return {
|
|
modern: p2shP2wpkhAddress(node, digibyte),
|
|
legacy: p2shP2wpkhAddress(node, digibyteLegacyP2SH),
|
|
};
|
|
}
|
|
export function p2wpkhAddress(node, network = digibyte) {
|
|
const { address } = payments().p2wpkh({
|
|
pubkey: Buffer.from(node.publicKey),
|
|
network,
|
|
});
|
|
if (!address)
|
|
throw new Error('p2wpkh derivation returned no address');
|
|
return address;
|
|
}
|
|
// BIP86 Taproot address using the x-only pubkey with no script tree,
|
|
// which applies the standard BIP86 tweak internally in bitcoinjs-lib.
|
|
export function p2trAddress(node, network = digibyte) {
|
|
ensureEcc(); // Taproot needs initEccLib; done on demand, once.
|
|
const internalPubkey = Buffer.from(node.publicKey.subarray(1, 33));
|
|
const { address } = payments().p2tr({ internalPubkey, network });
|
|
if (!address)
|
|
throw new Error('p2tr derivation returned no address');
|
|
return address;
|
|
}
|
|
//# sourceMappingURL=address.js.map
|