@VisibleForTesting Protos.Wallet toProtobuf() { lock.lock(); try { return WalletProtobufSerializer.toProtobuf(this); } finally { lock.unlock(); } } /**
/** * Returns the given wallet formatted as text. The text format is that used by protocol buffers and although it * can also be parsed using {@link TextFormat#merge(CharSequence, com.google.protobuf.Message.Builder)}, * it is designed more for debugging than storage. It is not well specified and wallets are largely binary data * structures anyway, consisting as they do of keys (large random numbers) and * {@link org.bitcoinj.core.Transaction}s which also mostly contain keys and hashes. */ public static String walletToText(Wallet wallet) { Protos.Wallet walletProto = toProtobuf(wallet); return TextFormat.printToString(walletProto); }
/** * Formats the given wallet (transactions and keys) to the given output stream in protocol buffer format.<p> * * Equivalent to <tt>walletToProto(wallet).writeTo(output);</tt> */ public static void writeWallet(Wallet wallet, OutputStream output) throws IOException { Protos.Wallet walletProto = toProtobuf(wallet); walletProto.writeTo(output); }