本文整理汇总了Java中org.bitcoinj.store.WalletProtobufSerializer类的典型用法代码示例。如果您正苦于以下问题:Java WalletProtobufSerializer类的具体用法?Java WalletProtobufSerializer怎么用?Java WalletProtobufSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WalletProtobufSerializer类属于org.bitcoinj.store包,在下文中一共展示了WalletProtobufSerializer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: restoreWalletFromProtobuf
import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
public static Wallet restoreWalletFromProtobuf(final InputStream is, final NetworkParameters expectedNetworkParameters) throws IOException
{
try
{
final Wallet wallet = new WalletProtobufSerializer().readWallet(is);
if (!wallet.getParams().equals(expectedNetworkParameters))
throw new IOException("bad wallet network parameters: " + wallet.getParams().getId());
return wallet;
}
catch (final UnreadableWalletException x)
{
throw new IOException("unreadable wallet", x);
}
}
示例2: walletToByteArray
import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
public static byte[] walletToByteArray(final Wallet wallet)
{
try
{
final ByteArrayOutputStream os = new ByteArrayOutputStream();
new WalletProtobufSerializer().writeWallet(wallet, os);
os.close();
return os.toByteArray();
}
catch (final IOException x)
{
throw new RuntimeException(x);
}
}
示例3: backups
import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
@Test
public void backups() throws Exception
{
final byte[] backup = Crypto.decryptBytes(readBackupFromResource("bitcoin-wallet-backup-testnet-3.50"), PASSWORD);
assertTrue(WalletProtobufSerializer.isWallet(new ByteArrayInputStream(backup)));
final byte[] backupCrLf = Crypto.decryptBytes(readBackupFromResource("bitcoin-wallet-backup-testnet-3.50-crlf"), PASSWORD);
assertTrue(WalletProtobufSerializer.isWallet(new ByteArrayInputStream(backupCrLf)));
}
示例4: saveToFileStream
import org.bitcoinj.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();
}
}
示例5: loadFromFileStream
import org.bitcoinj.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;
}
示例6: roundTripClientWallet
import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
private static Wallet roundTripClientWallet(Wallet wallet) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
new WalletProtobufSerializer().writeWallet(wallet, bos);
org.bitcoinj.wallet.Protos.Wallet proto = WalletProtobufSerializer.parseToProto(new ByteArrayInputStream(bos.toByteArray()));
StoredPaymentChannelClientStates state = new StoredPaymentChannelClientStates(null, failBroadcaster);
return new WalletProtobufSerializer().readWallet(wallet.getParams(), new WalletExtension[] { state }, proto);
}
示例7: roundTripServerWallet
import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
private static Wallet roundTripServerWallet(Wallet wallet) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
new WalletProtobufSerializer().writeWallet(wallet, bos);
StoredPaymentChannelServerStates state = new StoredPaymentChannelServerStates(null, failBroadcaster);
org.bitcoinj.wallet.Protos.Wallet proto = WalletProtobufSerializer.parseToProto(new ByteArrayInputStream(bos.toByteArray()));
return new WalletProtobufSerializer().readWallet(wallet.getParams(), new WalletExtension[] { state }, proto);
}
示例8: transactionSignersShouldBeSerializedAlongWithWallet
import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
@Test
public void transactionSignersShouldBeSerializedAlongWithWallet() throws Exception {
TransactionSigner signer = new NopTransactionSigner(true);
wallet.addTransactionSigner(signer);
assertEquals(2, wallet.getTransactionSigners().size());
Protos.Wallet protos = new WalletProtobufSerializer().walletToProto(wallet);
wallet = new WalletProtobufSerializer().readWallet(params, null, protos);
assertEquals(2, wallet.getTransactionSigners().size());
assertTrue(wallet.getTransactionSigners().get(1).isReady());
}
示例9: createWalletProtobufSerializerExtension
import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
@Override
public WalletProtobufSerializerExtension createWalletProtobufSerializerExtension(WalletProtobufSerializer walletProtobufSerializer) {
return DashWalletProtobufSerializerExtension.INSTANCE;
}
示例10: roundTrip
import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
private Wallet roundTrip(Wallet wallet) throws UnreadableWalletException {
Protos.Wallet protos = new WalletProtobufSerializer().walletToProto(wallet);
return new WalletProtobufSerializer().readWallet(params, null, protos);
}