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


Java WalletProtobufSerializer类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:13,代码来源:Wallet.java

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

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

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

示例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;

}
 
开发者ID:bither,项目名称:bither-android,代码行数:10,代码来源:UpgradeUtil.java

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


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