Socket
Socket
Sign inDemoInstall

@marinade.finance/ledger-utils

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marinade.finance/ledger-utils - npm Package Compare versions

Comparing version 2.0.7 to 2.0.8

2

package.json
{
"name": "@marinade.finance/ledger-utils",
"version": "2.0.7",
"version": "2.0.8",
"description": "Utility functions for interacting with the Ledger from CLI",

@@ -5,0 +5,0 @@ "repository": {

@@ -32,2 +32,3 @@ import Solana from '@ledgerhq/hw-app-solana';

private static findByPubkey;
private static generateAllCombinations;
/**

@@ -34,0 +35,0 @@ * Signing versioned transaction message with ledger

@@ -82,3 +82,3 @@ "use strict";

}
let transport;
let transport = undefined;
if (pubkey === undefined) {

@@ -92,16 +92,54 @@ // taking first device

for (const device of ledgerDevices) {
transport = await hw_transport_node_hid_noevents_1.default.open(device.path);
const solanaApi = new hw_app_solana_1.default(transport);
const tempTransport = await hw_transport_node_hid_noevents_1.default.open(device.path);
const solanaApi = new hw_app_solana_1.default(tempTransport);
const ledgerPubkey = await LedgerWallet.getPublicKey(solanaApi, derivedPath);
if (ledgerPubkey.equals(pubkey)) {
transport = tempTransport;
break; // the last found transport is the one we need
}
}
throw new Error('Available ledger devices does not provide pubkey ' +
pubkey.toBase58() +
' for derivation path ' +
derivedPath);
if (transport === undefined) {
// let's do some heuristic search, currently up to 25
const upTo = 25;
const derivedPathLength = derivedPath.split('/').length - 2; // 44'/501'/<number>
const allCombinations = LedgerWallet.generateAllCombinations(upTo, derivedPathLength);
for (const device of ledgerDevices) {
const tempTransport = await hw_transport_node_hid_noevents_1.default.open(device.path);
for (const combination of allCombinations) {
const derivedPath = exports.SOLANA_LEDGER_BIP44_BASE_PATH + combination.join('/');
const solanaApi = new hw_app_solana_1.default(tempTransport);
const ledgerPubkey = await LedgerWallet.getPublicKey(solanaApi, derivedPath);
if (ledgerPubkey.equals(pubkey)) {
console.log(`Using derived path ${derivedPath}, pubkey ${pubkey.toBase58()}`);
transport = tempTransport;
break; // the last found transport is the one we need
}
}
}
}
if (transport === undefined) {
throw new Error('Available ledger devices does not provide pubkey ' +
pubkey.toBase58() +
' for derivation path ' +
derivedPath);
}
}
return new hw_app_solana_1.default(transport);
}
static generateAllCombinations(max, maxLength) {
const combinations = [];
function generate(prefix, remainingLength) {
if (remainingLength === 0) {
combinations.push(prefix);
return;
}
for (let i = 0; i <= max; i++) {
generate([...prefix, i], remainingLength - 1);
}
}
for (let length = 1; length <= maxLength; length++) {
generate([], length);
}
return combinations;
}
/**

@@ -108,0 +146,0 @@ * Signing versioned transaction message with ledger

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc