WalletProtobufSerializer.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:cryptwallet 作者:
/**
 * Cheap test to see if input stream is a wallet. This checks for a magic value at the beginning of the stream.
 *
 * @param is
 *            input stream to test
 * @return true if input stream is a wallet
 */
public static boolean isWallet(InputStream is) {
    try {
        final CodedInputStream cis = CodedInputStream.newInstance(is);
        final int tag = cis.readTag();
        final int field = WireFormat.getTagFieldNumber(tag);
        if (field != 1) // network_identifier
            return false;
        final String network = cis.readString();
        return NetworkParameters.fromID(network) != null;
    } catch (IOException x) {
        return false;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号