Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
[3.0.8.0] Added support for custom keypath (#4221)
Browse files Browse the repository at this point in the history
* Added ledger support

* Fixed block explorer

* Added CL args

* Added a flag to ignore balance check

* Fixed explorer test

* Minor changes as per feedback

* Minor changes as per feedback

* Added global.json to lock the version

* DOwngraded to 2.1

* Removed unused tests

* Added keypath param for advanced users

Co-authored-by: Igor Goldobin <[email protected]>
  • Loading branch information
fenix2222 and fenix2222 authored Feb 17, 2021
1 parent c4d5176 commit f28c425
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/AddressOwnershipTool/LedgerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ public LedgerService(bool testnet)
this.blockExplorerClient = new BlockExplorerClient();
}

public async Task ExportAddressesAsync(int numberOfAddressesToScan, string destinationAddress, bool ignoreBalance)
public async Task ExportAddressesAsync(int numberOfAddressesToScan, string destinationAddress, bool ignoreBalance, string keyPath = null)
{
LedgerClient ledger = (await LedgerClient.GetHIDLedgersAsync()).First();

var numberOfIterations = string.IsNullOrEmpty(keyPath) ? numberOfAddressesToScan : 1;

// m / purpose' / coin_type' / account' / change / address_index
for (int index = 0; index < numberOfAddressesToScan; index++)
for (int index = 0; index < numberOfIterations; index++)
{
var key = new KeyPath($"m/44'/105'/0'/0/{index}");
var key = new KeyPath(string.IsNullOrEmpty(keyPath) ? $"m/44'/105'/0'/0/{index}" : keyPath);

GetWalletPubKeyResponse walletPubKey = await ledger.GetWalletPubKeyAsync(key);

Expand Down
9 changes: 8 additions & 1 deletion src/AddressOwnershipTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,18 @@ static async Task Main(string[] args)
}
}

arg = args.FirstOrDefault(a => a.StartsWith("-keypath"));
string path = null;
if (arg != null)
{
path = arg.Split('=')[1];
}

var ledgerService = new LedgerService(testnet);

try
{
await ledgerService.ExportAddressesAsync(numberOfAddressesToScan, destinationAddress, ignoreBalance);
await ledgerService.ExportAddressesAsync(numberOfAddressesToScan, destinationAddress, ignoreBalance, path);
}
catch (InvalidOperationException)
{
Expand Down

0 comments on commit f28c425

Please sign in to comment.