From 8c752975997681c9a5ab3eaa858a0b0067b77d3f Mon Sep 17 00:00:00 2001
From: parodyBit <58690522+parodyBit@users.noreply.github.com>
Date: Wed, 29 Dec 2021 17:14:23 -0700
Subject: [PATCH] Refactor Xpub

refactor(xpub): fix byte alignment when parsing path from index
---
 lib/src/crypto/hd_wallet/extended_public_key.dart | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/src/crypto/hd_wallet/extended_public_key.dart b/lib/src/crypto/hd_wallet/extended_public_key.dart
index 831f1e9..ff1cd0a 100644
--- a/lib/src/crypto/hd_wallet/extended_public_key.dart
+++ b/lib/src/crypto/hd_wallet/extended_public_key.dart
@@ -123,7 +123,7 @@ class Xpub extends ExtendedKey{
       BigInt currentIndex = bytesToBigInt(_index.sublist(i,i+4));
       lastIndex = _index.sublist(i,i+4);
       if (currentIndex < BigInt.from(1 << 31)) {
-       _path+='/${currentIndex.toString()}';
+       _path+='/${currentIndex}';
       } else {
         _path += '/${currentIndex - BigInt.from(1 << 31)}h';
       }
@@ -149,7 +149,7 @@ class Xpub extends ExtendedKey{
             + BigInt.from(1 << 31);
       indexParts.add(bigIntToBytes(value));
       } else {
-        indexParts.add(rightJustify(bigIntToBytes( BigInt.from(int.parse(element))),4,0));
+        indexParts.add(leftJustify(bigIntToBytes( BigInt.from(int.parse(element))),4,0));
       }
     });
     Uint8List indexData = concatBytes(indexParts);