@exodus/hw-ledger 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.2.4](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.2.3...@exodus/hw-ledger@2.2.4) (2024-01-23)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- build wallet policy with correct xpub ([#5488](https://github.com/ExodusMovement/exodus-hydra/issues/5488)) ([d25dd95](https://github.com/ExodusMovement/exodus-hydra/commit/d25dd9503828b957e3c6206758325bd21b0dffbe))
|
|
11
|
+
|
|
6
12
|
## [2.2.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.2.2...@exodus/hw-ledger@2.2.3) (2024-01-23)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
|
@@ -23,9 +23,7 @@ async function createHandler(transport) {
|
|
|
23
23
|
const psbtBuffer = params.signableTransaction;
|
|
24
24
|
const psbt = new PsbtV2();
|
|
25
25
|
psbt.deserialize(psbtBuffer);
|
|
26
|
-
const [purpose, coin, account] = splitBip44DerivationPath(params.derivationPaths[0]);
|
|
27
26
|
const fpr = await app.getMasterFingerprint();
|
|
28
|
-
const xpub = await app.getExtendedPubkey(`m/${purpose}/${coin}/${account}`);
|
|
29
27
|
const derivationPathToPublicKeyMap = Object.create(null);
|
|
30
28
|
for (const derivationPath of params.derivationPaths) {
|
|
31
29
|
derivationPathToPublicKeyMap[derivationPath] = await getPublicKey({
|
|
@@ -36,7 +34,7 @@ async function createHandler(transport) {
|
|
|
36
34
|
tagPsbtWithDerivationPaths(psbt, fpr, derivationPathToPublicKeyMap);
|
|
37
35
|
assertPsbtOnlyHasAllowedDerivationPaths(psbt, fpr, params.derivationPaths);
|
|
38
36
|
const signatures = [];
|
|
39
|
-
const walletPolicies = derivationPathsToWalletPolicy(fpr,
|
|
37
|
+
const walletPolicies = await derivationPathsToWalletPolicy(fpr, app, params.derivationPaths);
|
|
40
38
|
for (const walletPolicy of walletPolicies) {
|
|
41
39
|
const _signatures = await app.signPsbt(psbt.serialize(), walletPolicy, null);
|
|
42
40
|
signatures.push(..._signatures);
|
|
@@ -3,4 +3,4 @@ import { DefaultWalletPolicy, PsbtV2, WalletPolicy } from '@exodus/ledger-bitcoi
|
|
|
3
3
|
export declare function assertPsbtOnlyHasAllowedDerivationPaths(psbt: PsbtV2, masterFingerprint: string, derivationPaths: string[]): void;
|
|
4
4
|
export declare function tagPsbtWithDerivationPaths(psbt: PsbtV2, masterFingerprint: string, derivationPathToPublicKeyMap: Record<string, Buffer>): void;
|
|
5
5
|
export declare const getWalletPolicy: (fpr: string, xpub: string, purpose: string, coin: string, account: string) => DefaultWalletPolicy;
|
|
6
|
-
export declare function derivationPathsToWalletPolicy(fpr: string,
|
|
6
|
+
export declare function derivationPathsToWalletPolicy(fpr: string, app: any, derivationPaths: string[]): Promise<WalletPolicy[]>;
|
|
@@ -104,16 +104,18 @@ export const getWalletPolicy = (fpr, xpub, purpose, coin, account) => {
|
|
|
104
104
|
}[purpose];
|
|
105
105
|
return new DefaultWalletPolicy(desc, `[${fpr}/${purpose}/${coin}/${account}]${xpub}`);
|
|
106
106
|
};
|
|
107
|
-
export function derivationPathsToWalletPolicy(fpr,
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
export async function derivationPathsToWalletPolicy(fpr, app, derivationPaths) {
|
|
108
|
+
const splittedDerivationPaths = derivationPaths.map(splitBip44DerivationPath);
|
|
109
|
+
const dedupedPaths = Object.values(splittedDerivationPaths.reduce((prev, splittedDerivationPath) => {
|
|
110
|
+
const [purpose, coin, account] = splittedDerivationPath;
|
|
111
|
+
prev[[purpose, coin, account].toString()] = [purpose, coin, account];
|
|
112
|
+
return prev;
|
|
113
|
+
}, Object.create(null)));
|
|
114
|
+
const walletPolicies = [];
|
|
115
|
+
for (const dedupedPath of dedupedPaths) {
|
|
116
|
+
const [purpose, coin, account] = dedupedPath;
|
|
117
|
+
const xpub = await app.getExtendedPubkey(`m/${purpose}/${coin}/${account}`);
|
|
118
|
+
walletPolicies.push(getWalletPolicy(fpr, xpub, purpose, coin, account));
|
|
117
119
|
}
|
|
118
|
-
return
|
|
120
|
+
return walletPolicies;
|
|
119
121
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/hw-ledger",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "The ledger module",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"repository": {
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"ts-jest": "^29.0.3",
|
|
68
68
|
"typescript": "^4.7.3"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "78b65ec55ad9b053e0fa4aa3a2119a1537e1229e"
|
|
71
71
|
}
|