@exodus/address-provider
Advanced tools
Comparing version 12.0.1 to 12.1.0
@@ -6,2 +6,8 @@ # Change Log | ||
## [12.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/address-provider@12.0.1...@exodus/address-provider@12.1.0) (2024-07-30) | ||
### Features | ||
- add xpub to report ([#8110](https://github.com/ExodusMovement/exodus-hydra/issues/8110)) ([3236c9b](https://github.com/ExodusMovement/exodus-hydra/commit/3236c9b8eed3c5d96c5679495d168f611f3bf881)) | ||
## [12.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/address-provider@12.0.0...@exodus/address-provider@12.0.1) (2024-07-25) | ||
@@ -8,0 +14,0 @@ |
{ | ||
"name": "@exodus/address-provider", | ||
"version": "12.0.1", | ||
"version": "12.1.0", | ||
"description": "Address provider for deriving and tracking used and unused addresses.", | ||
@@ -47,3 +47,4 @@ "author": "Exodus Movement, Inc.", | ||
"lodash": "^4.17.21", | ||
"minimalistic-assert": "^1.0.1" | ||
"minimalistic-assert": "^1.0.1", | ||
"xpub-converter": "^1.0.2" | ||
}, | ||
@@ -89,3 +90,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "3995391eb48639b2d60ced5224a6a8f4902a2466" | ||
"gitHead": "b1a86a5efba1af4bcdbe91877c7a02f8e5cf517e" | ||
} |
import BipPath from 'bip32-path' | ||
import { set, pick, pickBy } from '@exodus/basic-utils' | ||
import KeyIdentifier from '@exodus/key-identifier' | ||
import convertXpub from 'xpub-converter' | ||
@@ -8,5 +10,7 @@ const lexicographicCompare = (a, b) => String(a).localeCompare(String(b)) | ||
assetsModule, | ||
publicKeyProvider, | ||
enabledWalletAccountsAtom, | ||
availableAssetNamesByWalletAccountAtom, | ||
addressProvider, | ||
legacyPrivToPub = {}, | ||
}) => ({ | ||
@@ -31,2 +35,30 @@ namespace: 'addressProvider', | ||
const getExtendedKeys = async ({ assetName, walletAccount, address }) => { | ||
const asset = assetsModule.getAsset(assetName) | ||
if (asset.curve === 'ed25519' || Object.hasOwn(legacyPrivToPub, assetName)) return | ||
const { keyIdentifier, purpose } = address.meta | ||
const parts = keyIdentifier.derivationPath.split('/') | ||
const xpubKeyIdentifier = new KeyIdentifier({ | ||
...keyIdentifier, | ||
derivationPath: parts.slice(0, 4).join('/'), | ||
}) | ||
try { | ||
const xpub = await publicKeyProvider.getExtendedPublicKey({ | ||
walletAccount: walletAccount.toString(), | ||
keyIdentifier: xpubKeyIdentifier, | ||
}) | ||
if ([84, 86, 49].includes(purpose)) { | ||
return { | ||
xpub, | ||
zpub: convertXpub(xpub, 'zpub'), | ||
} | ||
} | ||
return { xpub } | ||
} catch {} | ||
} | ||
const getAssetSourceAddresses = async ({ assetName, walletAccountName }) => { | ||
@@ -53,3 +85,7 @@ const walletAccount = enabledWalletAccounts[walletAccountName] | ||
[walletAccountName, assetName, purposeKey], | ||
{ address: address.toString(), chain }, | ||
{ | ||
address: address.toString(), | ||
chain, | ||
...(await getExtendedKeys({ walletAccount, assetName, address })), | ||
}, | ||
] | ||
@@ -91,2 +127,4 @@ } catch (error) { | ||
'addressProvider', | ||
'publicKeyProvider', | ||
'legacyPrivToPub?', | ||
], | ||
@@ -93,0 +131,0 @@ public: true, |
74511
1228
14
+ Addedxpub-converter@^1.0.2
+ Added@exodus/basic-utils@3.5.1(transitive)
+ Added@exodus/trezor-meta@3.5.0(transitive)
+ Addedxpub-converter@1.0.2(transitive)
- Removed@exodus/basic-utils@3.5.0(transitive)
- Removed@exodus/trezor-meta@3.4.0(transitive)