From b128bb895d43dfb97ddb4625425b975182753e5d Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 5 Apr 2024 13:49:13 +0200 Subject: [PATCH] add support for creating seedqr string --- .../com/sparrowwallet/drongo/wallet/SeedQR.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/SeedQR.java b/src/main/java/com/sparrowwallet/drongo/wallet/SeedQR.java index e26c06e..485dacd 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/SeedQR.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/SeedQR.java @@ -30,6 +30,20 @@ public class SeedQR { return new DeterministicSeed(words, null, System.currentTimeMillis(), DeterministicSeed.Type.BIP39); } + public static String getSeedQR(DeterministicSeed seed) { + if(seed.isEncrypted()) { + throw new IllegalStateException("Seed cannot be encrypted"); + } + + StringBuilder builder = new StringBuilder(); + for(String word : seed.getMnemonicCode()) { + int index = Bip39MnemonicCode.INSTANCE.getWordList().indexOf(word); + builder.append(String.format("%04d", index)); + } + + return builder.toString(); + } + public static DeterministicSeed getSeed(byte[] compactSeedQr) { byte[] seed;