Skip to content

Commit

Permalink
Refactor Xpub
Browse files Browse the repository at this point in the history
refactor(xpub): fix byte alignment when parsing path from index
  • Loading branch information
parodyBit committed Dec 30, 2021
1 parent 72bae0e commit 8c75297
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/crypto/hd_wallet/extended_public_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand All @@ -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);
Expand Down

0 comments on commit 8c75297

Please sign in to comment.