key-derivation
Heavily inspired by stellar-hd-wallet. Complies to BIP44 and SLIP10.
Usage
TODO: DEMONSTRATE API
const BigChainWallet = require('@s1seven/js-bigchain-key-derivation');
TODOs
Account discovery
In an extra module ?
- implement account discovery :
- BIP44 spec
- oip-hdmw
- bip32-utils
- With a query like :
async accountDiscovery(account: number | string, index: number, attempt = 0): Promise<boolean> {
const conn = new Connection(this.networkUrl);
const publicKey = this.getPublicKey(index, 'base58');
// ? only check unspent ?
const unspentTransactions = await conn.listOutputs(publicKey, false);
const spentTransactions = await conn.listOutputs(publicKey, true);
const transactions = [...unspentTransactions, ...spentTransactions];
if (transactions.length) {
return false;
}
if (!transactions.length) {
return this.accountDiscovery(account, (index += 1), (attempt += 1));
}
if (attempt === 20) {
return true;
}
return false;
}
- add third property if keypair has unspent transaction ?
- check that previous account has transaction history
DER / KeyObject / PEM encoding
- Add missing alg to export as DER/PEM/Keyobject X25519 private key