当前位置: 首页>>代码示例>>Java>>正文


Java WalletProtobufSerializer类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:17,代码来源:WalletUtils.java

示例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);
    }
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:15,代码来源:WalletUtils.java

示例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)));
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:10,代码来源:CryptoTest.java

示例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();
    }
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:13,代码来源:Wallet.java

示例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;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:11,代码来源:Wallet.java

示例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);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:ChannelConnectionTest.java

示例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);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:ChannelConnectionTest.java

示例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());
}
 
开发者ID:egordon,项目名称:CoinJoin,代码行数:11,代码来源:WalletTest.java

示例9: createWalletProtobufSerializerExtension

import org.bitcoinj.store.WalletProtobufSerializer; //导入依赖的package包/类
@Override
public WalletProtobufSerializerExtension createWalletProtobufSerializerExtension(WalletProtobufSerializer walletProtobufSerializer) {
    return DashWalletProtobufSerializerExtension.INSTANCE;
}
 
开发者ID:btcsoft,项目名称:coinj-dash,代码行数:5,代码来源:DashDefinition.java

示例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);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:5,代码来源:WalletTest.java


注:本文中的org.bitcoinj.store.WalletProtobufSerializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。