Fixed importer exception on Android

This commit is contained in:
Christian Basler 2016-10-07 22:08:55 +02:00
parent 3a0555e6e9
commit 784ed9ed4e

View File

@ -63,15 +63,15 @@ public class WifImporter {
Profile.Section section = entry.getValue(); Profile.Section section = entry.getValue();
BitmessageAddress address = Factory.createIdentityFromPrivateKey( BitmessageAddress address = Factory.createIdentityFromPrivateKey(
entry.getKey(), entry.getKey(),
getSecret(section.get("privsigningkey")), getSecret(section.get("privsigningkey")),
getSecret(section.get("privencryptionkey")), getSecret(section.get("privencryptionkey")),
section.get("noncetrialsperbyte", long.class), Long.parseLong(section.get("noncetrialsperbyte")),
section.get("payloadlengthextrabytes", long.class), Long.parseLong(section.get("payloadlengthextrabytes")),
Pubkey.Feature.bitfield(features) Pubkey.Feature.bitfield(features)
); );
if (section.containsKey("chan")) { if (section.containsKey("chan")) {
address.setChan(section.get("chan", boolean.class)); address.setChan(Boolean.parseBoolean(section.get("chan")));
} }
address.setAlias(section.get("label")); address.setAlias(section.get("label"));
identities.add(address); identities.add(address);
@ -82,10 +82,10 @@ public class WifImporter {
byte[] bytes = Base58.decode(walletImportFormat); byte[] bytes = Base58.decode(walletImportFormat);
if (bytes[0] != WIF_FIRST_BYTE) if (bytes[0] != WIF_FIRST_BYTE)
throw new IOException("Unknown format: 0x80 expected as first byte, but secret " + walletImportFormat + throw new IOException("Unknown format: 0x80 expected as first byte, but secret " + walletImportFormat +
" was " + bytes[0]); " was " + bytes[0]);
if (bytes.length != WIF_SECRET_LENGTH) if (bytes.length != WIF_SECRET_LENGTH)
throw new IOException("Unknown format: " + WIF_SECRET_LENGTH + throw new IOException("Unknown format: " + WIF_SECRET_LENGTH +
" bytes expected, but secret " + walletImportFormat + " was " + bytes.length + " long"); " bytes expected, but secret " + walletImportFormat + " was " + bytes.length + " long");
byte[] hash = cryptography().doubleSha256(bytes, 33); byte[] hash = cryptography().doubleSha256(bytes, 33);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {