add support for parsing compactseedqr without header or ec bytes

This commit is contained in:
Craig Raw 2023-07-23 12:45:43 +02:00
parent e15eb7c7f3
commit d7b97c99dc

View file

@ -31,6 +31,13 @@ public class SeedQR {
}
public static DeterministicSeed getSeed(byte[] compactSeedQr) {
byte[] seed;
if(compactSeedQr.length == 16 || compactSeedQr.length == 32) {
//Assume scan contains seed only
seed = compactSeedQr;
} else {
//Assume scan contains header, seed and EC bytes
if(compactSeedQr[0] != 0x41 && compactSeedQr[0] != 0x42) {
throw new IllegalArgumentException("Invalid CompactSeedQR header");
}
@ -49,7 +56,8 @@ public class SeedQR {
seedHex = qrHex.substring(3, qrHex.length() - 1); //24 word
}
byte[] seed = Utils.hexToBytes(seedHex);
seed = Utils.hexToBytes(seedHex);
}
if(seed.length < 16 || seed.length > 32 || seed.length % 4 > 0) {
throw new IllegalArgumentException("Invalid CompactSeedQR length: " + compactSeedQr.length);