Skip to content

Commit

Permalink
Add extended key property to SLIP10Node (#196)
Browse files Browse the repository at this point in the history
* Add extended key property to `SLIP10Node`

* Revert some unnecessary changes

* Fix test
  • Loading branch information
Mrtenz authored Nov 22, 2024
1 parent 536111b commit ba51cac
Show file tree
Hide file tree
Showing 4 changed files with 579 additions and 309 deletions.
28 changes: 2 additions & 26 deletions src/BIP44Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ import {
MIN_BIP_44_DEPTH,
} from './constants';
import type { SupportedCurve } from './curves';
import {
decodeExtendedKey,
encodeExtendedKey,
PRIVATE_KEY_VERSION,
PUBLIC_KEY_VERSION,
} from './extended-keys';
import { decodeExtendedKey, PRIVATE_KEY_VERSION } from './extended-keys';
import { SLIP10Node, validateBIP32Depth } from './SLIP10Node';
import { isHardened } from './utils';

Expand Down Expand Up @@ -279,26 +274,7 @@ export class BIP44Node implements BIP44NodeInterface {
}

public get extendedKey(): string {
const data = {
depth: this.depth,
parentFingerprint: this.parentFingerprint,
index: this.index,
chainCode: this.chainCodeBytes,
};

if (this.privateKeyBytes) {
return encodeExtendedKey({
...data,
version: PRIVATE_KEY_VERSION,
privateKey: this.privateKeyBytes,
});
}

return encodeExtendedKey({
...data,
version: PUBLIC_KEY_VERSION,
publicKey: this.publicKeyBytes,
});
return this.#node.extendedKey;
}

public get curve(): SupportedCurve {
Expand Down
Loading

0 comments on commit ba51cac

Please sign in to comment.