org.bitcoinj.wallet.Wallet.fromWatchingKey()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中org.bitcoinj.wallet.Wallet.fromWatchingKey()方法的一些代码示例,展示了Wallet.fromWatchingKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wallet.fromWatchingKey()方法的具体详情如下:
包路径:org.bitcoinj.wallet.Wallet
类名称:Wallet
方法名:fromWatchingKey

Wallet.fromWatchingKey介绍

[英]Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given watching key.
[中]创建一个钱包,用于跟踪与给定观看密钥所属的HD密钥层次结构之间的支付。

代码示例

代码示例来源:origin: fr.acinq/bitcoinj-core

public static Wallet fromWatchingKey(NetworkParameters params, DeterministicKey watchKey) {
  return fromWatchingKey(params, watchKey, false);
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given watching key. A
 * watching key corresponds to account zero in the recommended BIP32 key hierarchy. The key is specified in base58
 * notation and the creation time of the key. If you don't know the creation time, you can pass
 * {@link DeterministicHierarchy#BIP32_STANDARDISATION_TIME_SECS}.
 */
public static Wallet fromWatchingKeyB58(NetworkParameters params, String watchKeyB58, long creationTimeSeconds, boolean useSegwit) {
  final DeterministicKey watchKey = DeterministicKey.deserializeB58(null, watchKeyB58, params);
  watchKey.setCreationTimeSeconds(creationTimeSeconds);
  return fromWatchingKey(params, watchKey, useSegwit);
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given watching key. A
 * watching key corresponds to account zero in the recommended BIP32 key hierarchy. The key is specified in base58
 * notation and the creation time of the key. If you don't know the creation time, you can pass
 * {@link DeterministicHierarchy#BIP32_STANDARDISATION_TIME_SECS}.
 */
public static Wallet fromWatchingKeyB58(NetworkParameters params, String watchKeyB58, long creationTimeSeconds) {
  final DeterministicKey watchKey = DeterministicKey.deserializeB58(null, watchKeyB58, params);
  watchKey.setCreationTimeSeconds(creationTimeSeconds);
  return fromWatchingKey(params, watchKey);
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given watching key. A
 * watching key corresponds to account zero in the recommended BIP32 key hierarchy. The key is specified in base58
 * notation and the creation time of the key. If you don't know the creation time, you can pass
 * {@link DeterministicHierarchy#BIP32_STANDARDISATION_TIME_SECS}.
 */
public static Wallet fromWatchingKeyB58(NetworkParameters params, String watchKeyB58, long creationTimeSeconds) {
  final DeterministicKey watchKey = DeterministicKey.deserializeB58(null, watchKeyB58, params);
  watchKey.setCreationTimeSeconds(creationTimeSeconds);
  return fromWatchingKey(params, watchKey);
}

代码示例来源:origin: HashEngineering/dashj

/**
 * Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given watching key. The
 * account path is specified. The key is specified in base58 notation and the creation time of the key. If you don't
 * know the creation time, you can pass {@link DeterministicHierarchy#BIP32_STANDARDISATION_TIME_SECS}.
 */
public static Wallet fromWatchingKeyB58(NetworkParameters params, String watchKeyB58, long creationTimeSeconds) {
  final DeterministicKey watchKey = DeterministicKey.deserializeB58(null, watchKeyB58, params);
  watchKey.setCreationTimeSeconds(creationTimeSeconds);
  return fromWatchingKey(params, watchKey);
}

代码示例来源:origin: greenaddress/GreenBits

@Test
public void isWatching() {
  assertFalse(wallet.isWatching());
  Wallet watchingWallet = Wallet.fromWatchingKey(PARAMS, wallet.getWatchingKey().dropPrivateBytes().dropParent());
  assertTrue(watchingWallet.isWatching());
  wallet.encrypt(PASSWORD1);
  assertFalse(wallet.isWatching());
}

代码示例来源:origin: greenaddress/GreenBits

@Test (expected = ECKey.MissingPrivateKeyException.class)
public void completeTxPartiallySignedThrows() throws Exception {
  sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, CENT, wallet.freshReceiveKey());
  SendRequest req = SendRequest.emptyWallet(OTHER_ADDRESS);
  wallet.completeTx(req);
  // Delete the sigs
  for (TransactionInput input : req.tx.getInputs())
    input.clearScriptBytes();
  Wallet watching = Wallet.fromWatchingKey(PARAMS, wallet.getWatchingKey().dropParent().dropPrivateBytes());
  watching.completeTx(SendRequest.forTx(req.tx));
}

代码示例来源:origin: greenaddress/GreenBits

@Test
public void watchingWallet() throws Exception {
  DeterministicKey watchKey = wallet.getWatchingKey();
  String serialized = watchKey.serializePubB58(PARAMS);
  // Construct watching wallet.
  Wallet watchingWallet = Wallet.fromWatchingKey(PARAMS, DeterministicKey.deserializeB58(null, serialized, PARAMS));
  DeterministicKey key2 = watchingWallet.freshReceiveKey();
  assertEquals(myKey, key2);
  ECKey key = wallet.freshKey(KeyChain.KeyPurpose.CHANGE);
  key2 = watchingWallet.freshKey(KeyChain.KeyPurpose.CHANGE);
  assertEquals(key, key2);
  key.sign(Sha256Hash.ZERO_HASH);
  try {
    key2.sign(Sha256Hash.ZERO_HASH);
    fail();
  } catch (ECKey.MissingPrivateKeyException e) {
    // Expected
  }
  receiveATransaction(watchingWallet, myKey.toAddress(PARAMS));
  assertEquals(COIN, watchingWallet.getBalance());
  assertEquals(COIN, watchingWallet.getBalance(Wallet.BalanceType.AVAILABLE));
  assertEquals(ZERO, watchingWallet.getBalance(Wallet.BalanceType.AVAILABLE_SPENDABLE));
}

相关文章

微信公众号

最新文章

更多

Wallet类方法