本文整理汇总了Java中com.google.bitcoin.store.WalletProtobufSerializer类的典型用法代码示例。如果您正苦于以下问题:Java WalletProtobufSerializer类的具体用法?Java WalletProtobufSerializer怎么用?Java WalletProtobufSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WalletProtobufSerializer类属于com.google.bitcoin.store包,在下文中一共展示了WalletProtobufSerializer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveToFileStream
import com.google.bitcoin.store.WalletProtobufSerializer; //导入依赖的package包/类
/**
* Uses protobuf serialization to save the wallet to the given file stream. To learn more about this file format, see
* {@link WalletProtobufSerializer}.
*/
public void saveToFileStream(OutputStream f) throws IOException {
lock.lock();
try {
new WalletProtobufSerializer().writeWallet(this, f);
} finally {
lock.unlock();
}
}
示例2: loadFromFileStream
import com.google.bitcoin.store.WalletProtobufSerializer; //导入依赖的package包/类
/**
* Returns a wallet deserialized from the given input stream.
*/
public static Wallet loadFromFileStream(InputStream stream) throws UnreadableWalletException {
Wallet wallet = new WalletProtobufSerializer().readWallet(stream);
if (!wallet.isConsistent()) {
log.error("Loaded an inconsistent wallet");
}
return wallet;
}
示例3: roundTripClientWallet
import com.google.bitcoin.store.WalletProtobufSerializer; //导入依赖的package包/类
private static Wallet roundTripClientWallet(Wallet wallet) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
new WalletProtobufSerializer().writeWallet(wallet, bos);
Wallet wallet2 = new Wallet(wallet.getParams());
wallet2.addExtension(new StoredPaymentChannelClientStates(wallet2, failBroadcaster));
new WalletProtobufSerializer().readWallet(WalletProtobufSerializer.parseToProto(new ByteArrayInputStream(bos.toByteArray())), wallet2);
return wallet2;
}
示例4: roundTripServerWallet
import com.google.bitcoin.store.WalletProtobufSerializer; //导入依赖的package包/类
private static Wallet roundTripServerWallet(Wallet wallet) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
new WalletProtobufSerializer().writeWallet(wallet, bos);
Wallet wallet2 = new Wallet(wallet.getParams());
wallet2.addExtension(new StoredPaymentChannelServerStates(wallet2, failBroadcaster));
new WalletProtobufSerializer().readWallet(WalletProtobufSerializer.parseToProto(new ByteArrayInputStream(bos.toByteArray())), wallet2);
return wallet2;
}
示例5: loadECKey
import com.google.bitcoin.store.WalletProtobufSerializer; //导入依赖的package包/类
private static ECKey loadECKey(File walletFile) throws Exception {
FileInputStream walletStream = null;
walletStream = new FileInputStream(walletFile);
ECKey ecKey = new
WalletProtobufSerializer()
.readWallet(walletStream);
return ecKey;
}
示例6: loadFromFileStream
import com.google.bitcoin.store.WalletProtobufSerializer; //导入依赖的package包/类
/**
* Returns a wallet deserialized from the given input stream.
*/
public static Wallet loadFromFileStream(InputStream stream) throws IOException {
// Determine what kind of wallet stream this is: Java Serialization or protobuf format.
stream = new BufferedInputStream(stream);
stream.mark(100);
boolean serialization = stream.read() == 0xac && stream.read() == 0xed;
stream.reset();
Wallet wallet;
if (serialization) {
ObjectInputStream ois = null;
try {
ois = new ObjectInputStream(stream);
wallet = (Wallet) ois.readObject();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (ois != null) ois.close();
}
} else {
wallet = new WalletProtobufSerializer().readWallet(stream);
}
if (!wallet.isConsistent()) {
log.error("Loaded an inconsistent wallet");
}
return wallet;
}