3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 23:03:04 +00:00

Tweak WalletExtension slightly.

This commit is contained in:
Matt Corallo 2013-06-04 19:02:00 +02:00 committed by Mike Hearn
parent a7987585b8
commit a3f1fe5390
3 changed files with 19 additions and 11 deletions

View File

@ -40,5 +40,5 @@ public interface WalletExtension {
/** Returns bytes that will be saved in the wallet. */
public byte[] serializeWalletExtension();
/** Loads the contents of this object from the wallet. */
public void deserializeWalletExtension(byte[] data);
public void deserializeWalletExtension(Wallet containingWallet, byte[] data) throws Exception;
}

View File

@ -16,6 +16,17 @@
package com.google.bitcoin.store;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.HashMap;
import java.util.ListIterator;
import java.util.Map;
import com.google.bitcoin.core.*;
import com.google.bitcoin.core.TransactionConfidence.ConfidenceType;
import com.google.bitcoin.crypto.EncryptedPrivateKey;
@ -29,14 +40,6 @@ import org.bitcoinj.wallet.Protos.Wallet.EncryptionType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@ -404,7 +407,12 @@ public class WalletProtobufSerializer {
}
} else {
log.info("Loading wallet extension {}", id);
extension.deserializeWalletExtension(extProto.getData().toByteArray());
try {
extension.deserializeWalletExtension(wallet, extProto.getData().toByteArray());
} catch (Exception e) {
if (extProto.getMandatory())
throw new IllegalArgumentException("Unknown mandatory extension in wallet: " + id);
}
}
}
}

View File

@ -305,7 +305,7 @@ public class WalletProtobufSerializerTest {
}
@Override
public void deserializeWalletExtension(byte[] data) {
public void deserializeWalletExtension(Wallet wallet, byte[] data) {
assertArrayEquals(this.data, data);
}
}