- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.bitcoinj.wallet.WalletProtobufSerializer
类的一些代码示例,展示了WalletProtobufSerializer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WalletProtobufSerializer
类的具体详情如下:
包路径:org.bitcoinj.wallet.WalletProtobufSerializer
类名称:WalletProtobufSerializer
[英]Serialize and de-serialize a wallet to a byte stream containing a protocol buffer. Protocol buffers are a data interchange format developed by Google with an efficient binary representation, a type safe specification language and compilers that generate code to work with those data structures for many languages. Protocol buffers can have their format evolved over time: conceptually they represent data using (tag, length, value) tuples. The format is defined by the wallet.proto file in the bitcoinj source distribution.
This class is used through its static methods. The most common operations are writeWallet and readWallet, which do the obvious operations on Output/InputStreams. You can use a java.io.ByteArrayInputStream and equivalent java.io.ByteArrayOutputStream if you'd like byte arrays instead. The protocol buffer can also be manipulated in its object form if you'd like to modify the flattened data structure before serialization to binary.
You can extend the wallet format with additional fields specific to your application if you want, but make sure to either put the extra data in the provided extension areas, or select tag numbers that are unlikely to be used by anyone else.
[中]将钱包序列化并反序列化为包含protocol buffer的字节流。协议缓冲区是谷歌开发的一种数据交换格式,具有高效的二进制表示、类型安全规范语言和编译器,这些编译器生成代码,用于处理多种语言的数据结构。协议缓冲区的格式可以随着时间的推移而变化:从概念上讲,它们使用(标记、长度、值)元组表示数据。格式由钱包定义。bitcoinj源发行版中的原型文件。
此类通过其静态方法使用。最常见的操作是writeWallet和readWallet,它们对输出/输入流执行明显的操作。你可以使用java。伊奥。ByteArrayInputStream和等效java。伊奥。ByteArrayOutputStream,如果您想要字节数组的话。如果您想在序列化为二进制之前修改平坦的数据结构,还可以以对象形式操纵协议缓冲区。
如果需要,您可以使用特定于应用程序的其他字段扩展钱包格式,但请确保将额外数据放在提供的扩展区域中,或者选择其他人不太可能使用的标签号。
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
private Wallet loadWallet(boolean shouldReplayWallet) throws Exception {
Wallet wallet;
FileInputStream walletStream = new FileInputStream(vWalletFile);
try {
List<WalletExtension> extensions = provideWalletExtensions();
WalletExtension[] extArray = extensions.toArray(new WalletExtension[extensions.size()]);
Protos.Wallet proto = WalletProtobufSerializer.parseToProto(walletStream);
final WalletProtobufSerializer serializer;
if (walletFactory != null)
serializer = new WalletProtobufSerializer(walletFactory);
else
serializer = new WalletProtobufSerializer();
wallet = serializer.readWallet(params, extArray, proto);
if (shouldReplayWallet)
wallet.reset();
} finally {
walletStream.close();
}
return wallet;
}
代码示例来源:origin: greenaddress/GreenBits
private Wallet roundTrip(Wallet wallet) throws UnreadableWalletException {
Protos.Wallet protos = new WalletProtobufSerializer().walletToProto(wallet);
return new WalletProtobufSerializer().readWallet(PARAMS, null, protos);
}
代码示例来源:origin: greenaddress/GreenBits
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);
}
代码示例来源:origin: greenaddress/GreenBits
/**
* 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();
}
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/** Returns a wallet deserialized from the given input stream and wallet extensions. */
public static Wallet loadFromFileStream(InputStream stream, @Nullable WalletExtension... walletExtensions) throws UnreadableWalletException {
Wallet wallet = new WalletProtobufSerializer().readWallet(stream, walletExtensions);
if (!wallet.isConsistent()) {
log.error("Loaded an inconsistent wallet");
}
return wallet;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
readTransaction(txProto, wallet.getParams());
WalletTransaction wtx = connectTransactionOutputs(params, txProto);
wallet.addWalletTransaction(wtx);
wallet.setLastBlockSeenHash(null);
} else {
wallet.setLastBlockSeenHash(byteStringToHash(walletProto.getLastSeenBlockHash()));
loadExtensions(wallet, extensions != null ? extensions : new WalletExtension[0], walletProto);
代码示例来源:origin: greenaddress/GreenBits
private static Wallet roundTrip(Wallet wallet) throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
new WalletProtobufSerializer().writeWallet(wallet, output);
ByteArrayInputStream test = new ByteArrayInputStream(output.toByteArray());
assertTrue(WalletProtobufSerializer.isWallet(test));
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
return new WalletProtobufSerializer().readWallet(input);
}
代码示例来源:origin: fr.acinq/bitcoinj-core
Protos.Wallet walletProto = parseToProto(input);
final String paramsID = walletProto.getNetworkIdentifier();
NetworkParameters params = NetworkParameters.fromID(paramsID);
if (params == null)
throw new UnreadableWalletException("Unknown network parameters ID " + paramsID);
return readWallet(params, extensions, walletProto, forceReset);
} catch (IOException e) {
throw new UnreadableWalletException("Could not parse input stream to protobuf", e);
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
Protos.Transaction txProto = makeTxProto(wtx);
walletBuilder.addTransaction(txProto);
walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash));
walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight());
populateExtensions(wallet, walletBuilder);
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
Protos.Transaction.Builder txBuilder = Protos.Transaction.newBuilder();
txBuilder.setPool(getProtoPool(wtx))
.setHash(hashToByteString(tx.getHash()))
.setVersion((int) tx.getVersion());
Protos.TransactionInput.Builder inputBuilder = Protos.TransactionInput.newBuilder()
.setScriptBytes(ByteString.copyFrom(input.getScriptBytes()))
.setTransactionOutPointHash(hashToByteString(input.getOutpoint().getHash()))
.setTransactionOutPointIndex((int) input.getOutpoint().getIndex());
if (input.hasSequence())
Sha256Hash spendingHash = spentBy.getParentTransaction().getHash();
int spentByTransactionIndex = spentBy.getParentTransaction().getInputs().indexOf(spentBy);
outputBuilder.setSpentByTransactionHash(hashToByteString(spendingHash))
.setSpentByTransactionIndex(spentByTransactionIndex);
if (appearsInHashes != null) {
for (Map.Entry<Sha256Hash, Integer> entry : appearsInHashes.entrySet()) {
txBuilder.addBlockHash(hashToByteString(entry.getKey()));
txBuilder.addBlockRelativityOffsets(entry.getValue());
TransactionConfidence confidence = tx.getConfidence();
Protos.TransactionConfidence.Builder confidenceBuilder = Protos.TransactionConfidence.newBuilder();
writeConfidence(txBuilder, confidence, confidenceBuilder);
代码示例来源:origin: HashEngineering/dashj
Protos.Wallet proto = WalletProtobufSerializer.parseToProto(stream);
proto = attemptHexConversion(proto);
System.out.println(proto.toString());
|| (action == ActionEnum.SYNC
&& options.has("force"));
WalletProtobufSerializer loader = new WalletProtobufSerializer();
if (options.has("ignore-mandatory-extensions"))
loader.setRequireMandatoryExtensions(false);
walletInputStream = new BufferedInputStream(new FileInputStream(walletFile));
wallet = loader.readWallet(walletInputStream, forceReset, (WalletExtension[])(null));
if (!wallet.getParams().equals(params)) {
System.err.println("Wallet does not match requested network parameters: " +
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* <p>Loads wallet data from the given protocol buffer and inserts it into the given Wallet object. This is primarily
* useful when you wish to pre-register extension objects. Note that if loading fails the provided Wallet object
* may be in an indeterminate state and should be thrown away.</p>
*
* <p>A wallet can be unreadable for various reasons, such as inability to open the file, corrupt data, internally
* inconsistent data, a wallet extension marked as mandatory that cannot be handled and so on. You should always
* handle {@link UnreadableWalletException} and communicate failure to the user in an appropriate manner.</p>
*
* @throws UnreadableWalletException thrown in various error conditions (see description).
*/
public Wallet readWallet(InputStream input, @Nullable WalletExtension... walletExtensions) throws UnreadableWalletException {
return readWallet(input, false, walletExtensions);
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void testLastBlockSeenHash() throws Exception {
// Test the lastBlockSeenHash field works.
// LastBlockSeenHash should be empty if never set.
Wallet wallet = new Wallet(PARAMS);
Protos.Wallet walletProto = new WalletProtobufSerializer().walletToProto(wallet);
ByteString lastSeenBlockHash = walletProto.getLastSeenBlockHash();
assertTrue(lastSeenBlockHash.isEmpty());
// Create a block.
Block block = PARAMS.getDefaultSerializer().makeBlock(BlockTest.blockBytes);
Sha256Hash blockHash = block.getHash();
wallet.setLastBlockSeenHash(blockHash);
wallet.setLastBlockSeenHeight(1);
// Roundtrip the wallet and check it has stored the blockHash.
Wallet wallet1 = roundTrip(wallet);
assertEquals(blockHash, wallet1.getLastBlockSeenHash());
assertEquals(1, wallet1.getLastBlockSeenHeight());
// Test the Satoshi genesis block (hash of all zeroes) is roundtripped ok.
Block genesisBlock = MainNetParams.get().getGenesisBlock();
wallet.setLastBlockSeenHash(genesisBlock.getHash());
Wallet wallet2 = roundTrip(wallet);
assertEquals(genesisBlock.getHash(), wallet2.getLastBlockSeenHash());
}
代码示例来源:origin: HashEngineering/dashj
if (spendingTx == null) {
throw new UnreadableWalletException(String.format(Locale.US, "Could not connect %s to %s",
tx.getHashAsString(), byteStringToHash(spentByTransactionHash)));
Protos.TransactionConfidence confidenceProto = txProto.getConfidence();
TransactionConfidence confidence = tx.getConfidence();
readConfidence(params, tx, confidenceProto, confidence);
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* 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 void writeWallet(Wallet wallet, OutputStream output) throws IOException {
Protos.Wallet walletProto = walletToProto(wallet);
walletProto.writeTo(output);
}
代码示例来源:origin: fr.acinq/bitcoinj-core
confidenceBuilder.setOverridingTransaction(hashToByteString(overridingHash));
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
TransactionOutPoint outpoint = new TransactionOutPoint(params,
inputProto.getTransactionOutPointIndex() & 0xFFFFFFFFL,
byteStringToHash(inputProto.getTransactionOutPointHash())
);
Coin value = inputProto.hasValue() ? Coin.valueOf(inputProto.getValue()) : null;
if (txProto.getBlockRelativityOffsetsCount() > 0)
relativityOffset = txProto.getBlockRelativityOffsets(i);
tx.addBlockAppearance(byteStringToHash(blockHash), relativityOffset);
Sha256Hash protoHash = byteStringToHash(txProto.getHash());
if (!tx.getHash().equals(protoHash))
throw new UnreadableWalletException(String.format(Locale.US, "Transaction did not deserialize completely: %s vs %s", tx.getHash(), protoHash));
if (txMap.containsKey(txProto.getHash()))
throw new UnreadableWalletException("Wallet contained duplicate transaction " + byteStringToHash(txProto.getHash()));
txMap.put(txProto.getHash(), tx);
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
readTransaction(txProto, wallet.getParams());
WalletTransaction wtx = connectTransactionOutputs(params, txProto);
wallet.addWalletTransaction(wtx);
wallet.setLastBlockSeenHash(null);
} else {
wallet.setLastBlockSeenHash(byteStringToHash(walletProto.getLastSeenBlockHash()));
loadExtensions(wallet, extensions != null ? extensions : new WalletExtension[0], walletProto);
代码示例来源:origin: greenaddress/GreenBits
/** Returns a wallet deserialized from the given input stream and wallet extensions. */
public static Wallet loadFromFileStream(InputStream stream, @Nullable WalletExtension... walletExtensions) throws UnreadableWalletException {
Wallet wallet = new WalletProtobufSerializer().readWallet(stream, walletExtensions);
if (!wallet.isConsistent()) {
log.error("Loaded an inconsistent wallet");
}
return wallet;
}
代码示例来源:origin: greenaddress/GreenBits
Protos.Wallet walletProto = parseToProto(input);
final String paramsID = walletProto.getNetworkIdentifier();
NetworkParameters params = NetworkParameters.fromID(paramsID);
if (params == null)
throw new UnreadableWalletException("Unknown network parameters ID " + paramsID);
return readWallet(params, extensions, walletProto, forceReset);
} catch (IOException e) {
throw new UnreadableWalletException("Could not parse input stream to protobuf", e);
我正在尝试接收有关 的通知新品 比特币区块链中的区块。我正在使用此代码,但这会从 2010 年左右开始打印数百个块。 import org.bitcoinj.core.*; import org.bi
给定三条信息:消息(字符串)、签名(字符串)和公共(public)地址(字符串),我想验证签名。在 Javascript、Python 和 PHP 库中,这是一个简单的方法调用。然而,在 Bitcoi
我正在尝试按照 BitcoinJS page 上的说明构建 Bitcoinjs 以进行浏览器测试。 (包括在下面)。 $ npm install -g bitcoinjs-lib $ npm -g i
本文整理了Java中org.bitcoinj.wallet.WalletProtobufSerializer类的一些代码示例,展示了WalletProtobufSerializer类的具体用法。这些代
本文整理了Java中org.bitcoinj.crypto.X509Utils类的一些代码示例,展示了X509Utils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/M
我对比特币网络交易的理解是新的。 我可以在同一笔比特币交易中将比特币发送到一个地址,同时将另一笔金额发送到另一个地址吗? 最佳答案 是的,你可以。 大多数比特币交易都有第二个收件人地址 change来
我已经创建了 P2SH 地址并将硬币发送到该地址 https://www.blocktrail.com/tBTC/address/2N8Xu6rNAwssXtP2XPjSTuT2ViWQoPeHr3r
找到一篇解释如何从公钥生成比特币地址的文章: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresse
我正在尝试使用 bitcoinj 作为一个简单的地址观察器。我正在使用 WalletAppKit,我在其中添加了地址: Address address = new Address(params, "m
我正在尝试学习 bitcoinj API,并在下面编写了测试代码。我创建了一个帐户: http://tpfaucet.appspot.com/ 所以我可以使用假硬币并测试发送/接收。当我登录 URL
我正在开发一个使用比特币支付方式的应用程序。它使用bitcoinj java库。但我有一个问题: 我正在将 BTC 发送到钱包。 它说交易已收到,但当然没有确认。我正在创建 future 的事件监听器
有人可以解释一下我如何使用 bitcoinjs 发送比特币交易吗???我已经使用 bitcoinjs 设置了两个钱包。 我想从这里发送 100000 聪:1G4iprWu7Q8tNbQLA8UBM2G
我的目标是监视一个公共(public)比特币地址,并在向该地址发送钱时打印到控制台。就这样。我暂时使用之前在 Bitcoin Core 中生成的地址。 我正在做以下事情: NetworkParame
我正在尝试使用 bitcoinj 获取原始 block 。我使用 Block.bitcoinSerialize() 来获取每个 block 下载时的字节,但不包括交易。我怎样才能获得完整的原始 blo
首先面临着 BitcoinJ FrameWork 中无休止的待处理交易 主要文档说可以通过Replace-By-Fee来制作。因此,您需要获取旧交易并创建一个新交易,但基于之前的交易。 听起来不错,但
首先,我使用 BIP32 使用 mnemonics 创建 HD Wallet。 现在我想为每次接收使用 xpub 和 xpriv 生成带有私钥的新子地址。 然后,例如,我在 2 个子地址中收到了 BT
本文整理了Java中org.bitcoinj.wallet.WalletProtobufSerializer.byteStringToHash()方法的一些代码示例,展示了WalletProtobuf
本文整理了Java中org.bitcoinj.wallet.WalletProtobufSerializer.readConfidence()方法的一些代码示例,展示了WalletProtobufSe
本文整理了Java中org.bitcoinj.wallet.WalletProtobufSerializer.makeTxProto()方法的一些代码示例,展示了WalletProtobufSeria
本文整理了Java中org.bitcoinj.wallet.WalletProtobufSerializer.writeConfidence()方法的一些代码示例,展示了WalletProtobufS
我是一名优秀的程序员,十分优秀!