mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
add support for parsing compactseedqr without header or ec bytes
This commit is contained in:
parent
e15eb7c7f3
commit
d7b97c99dc
1 changed files with 24 additions and 16 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue