org.bitcoinj.core.Transaction.getHash()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(152)

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

Transaction.getHash介绍

[英]Returns the transaction hash as you see them in the block explorer.
[中]返回在块资源管理器中看到的事务哈希。

代码示例

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

/**
 * Returns the transaction hash (aka txid) as you see them in block explorers. It is used as a reference by
 * transaction inputs via outpoints.
 */
@Override
public Sha256Hash getHash() {
  return getHash(false);
}

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

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  return getHash().equals(((Transaction)o).getHash());
}

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

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  return getHash().equals(((Transaction)o).getHash());
}

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

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  return getHash().equals(((Transaction)o).getHash());
}

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

@Override public void onSuccess(Transaction transaction) {
  log.info("TX {} propagated, channel successfully closed.", transaction.getHash());
  stateMachine.transition(State.CLOSED);
  closedFuture.set(transaction);
}

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

@Override public void onSuccess(Transaction transaction) {
  log.info("TX {} propagated, channel successfully closed.", transaction.getHash());
  stateMachine.transition(State.CLOSED);
  closedFuture.set(transaction);
}

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

@Override public void onSuccess(Transaction transaction) {
  log.info("TX {} propagated, channel successfully closed.", transaction.getHash());
  stateMachine.transition(State.CLOSED);
  closedFuture.set(transaction);
}

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

@Override public void onSuccess(Transaction transaction) {
  log.info("TX {} propagated, channel successfully closed.", transaction.getHash());
  stateMachine.transition(State.CLOSED);
  closedFuture.set(transaction);
}

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

@Override
  public int compare(final Transaction tx1, final Transaction tx2) {
    final long time1 = tx1.getUpdateTime().getTime();
    final long time2 = tx2.getUpdateTime().getTime();
    final int updateTimeComparison = -(Longs.compare(time1, time2));
    //If time1==time2, compare by tx hash to make comparator consistent with equals
    return updateTimeComparison != 0 ? updateTimeComparison : tx1.getHash().compareTo(tx2.getHash());
  }
};

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

@Override
public void onSuccess(List<Transaction> dependencies) {
  try {
    log.info("{}: Dependency download complete!", getAddress());
    wallet.receivePending(tx, dependencies);
  } catch (VerificationException e) {
    log.error("{}: Wallet failed to process pending transaction {}", getAddress(), tx.getHash());
    log.error("Error was: ", e);
    // Not much more we can do at this point.
  }
}

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

@Override
public void onSuccess(List<Transaction> dependencies) {
  try {
    log.info("{}: Dependency download complete!", getAddress());
    wallet.receivePending(tx, dependencies);
  } catch (VerificationException e) {
    log.error("{}: Wallet failed to process pending transaction {}", getAddress(), tx.getHash());
    log.error("Error was: ", e);
    // Not much more we can do at this point.
  }
}

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

@Override
@VisibleForTesting synchronized void doStoreChannelInWallet(Sha256Hash id) {
  StoredPaymentChannelClientStates channels = (StoredPaymentChannelClientStates)
      wallet.getExtensions().get(StoredPaymentChannelClientStates.EXTENSION_ID);
  checkNotNull(channels, "You have not added the StoredPaymentChannelClientStates extension to the wallet.");
  checkState(channels.getChannel(id, multisigContract.getHash()) == null);
  storedChannel = new StoredClientChannel(getMajorVersion(), id, multisigContract, refundTx, myKey, serverKey, valueToMe, refundFees, 0, true);
  channels.putChannel(storedChannel);
}

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

@Override
@VisibleForTesting synchronized void doStoreChannelInWallet(Sha256Hash id) {
  StoredPaymentChannelClientStates channels = (StoredPaymentChannelClientStates)
      wallet.getExtensions().get(StoredPaymentChannelClientStates.EXTENSION_ID);
  checkNotNull(channels, "You have not added the StoredPaymentChannelClientStates extension to the wallet.");
  checkState(channels.getChannel(id, multisigContract.getHash()) == null);
  storedChannel = new StoredClientChannel(getMajorVersion(), id, multisigContract, refundTx, myKey, serverKey, valueToMe, refundFees, 0, true);
  channels.putChannel(storedChannel);
}

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

@Override
@VisibleForTesting synchronized void doStoreChannelInWallet(Sha256Hash id) {
  StoredPaymentChannelClientStates channels = (StoredPaymentChannelClientStates)
      wallet.getExtensions().get(StoredPaymentChannelClientStates.EXTENSION_ID);
  checkNotNull(channels, "You have not added the StoredPaymentChannelClientStates extension to the wallet.");
  checkState(channels.getChannel(id, contract.getHash()) == null);
  storedChannel = new StoredClientChannel(getMajorVersion(), id, contract, refundTx, myKey, serverKey, valueToMe, refundFees, expiryTime, true);
  channels.putChannel(storedChannel);
}

代码示例来源:origin: Coinomi/coinomi-android

public Sha256Hash getTxHash() {
  if (isDetached()) {
    return checkNotNull(txHash);
  } else {
    return getParentTransaction().getHash();
  }
}

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

/** Finds whether txA spends txB */
boolean spends(Transaction txA, Transaction txB) {
  for (TransactionInput txInput : txA.getInputs()) {
    if (txInput.getOutpoint().getHash().equals(txB.getHash())) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: blockchain/thunder

private void onChannelEstablished () {
    establishProgress.channel.anchorTxHash = establishProgress.channel.anchorTx.getHash();
    establishProgress.channel.isReady = true;
    dbHandler.saveChannel(establishProgress.channel);
    blockchainHelper.broadcastTransaction(establishProgress.channel.anchorTx);

//        channelManager.onExchangeDone(channel, this::onEnoughConfirmations);
    this.onEnoughConfirmations();

    if (channelOpenListener != null) {
      channelOpenListener.onStart(new SuccessResult());
    }
  }

代码示例来源:origin: blockchain/thunder

public void fillAnchorTransactionWithoutSignatures (WalletHelper walletHelper) {
  long totalAmount = channelStatus.amountServer + channelStatus.amountClient;
  if (anchorTx == null) {
    Script anchorScriptServer = getAnchorScriptOutput();
    Script anchorScriptServerP2SH = ScriptBuilder.createP2SHOutputScript(anchorScriptServer);
    anchorTx = new Transaction(Constants.getNetwork());
    anchorTx.addOutput(Coin.valueOf(totalAmount), anchorScriptServerP2SH);
  }
  anchorTx = walletHelper.addInputs(anchorTx, channelStatus.amountServer, channelStatus.feePerByte);
  anchorTxHash = anchorTx.getHash();
}

代码示例来源:origin: blockchain/unused-My-Wallet-V3-jar

@Test
public void applyBip69() throws Exception {
  //Lets just use some random tx that actually complies with BIP69 ( d82bec54384bb6068c3a79aef25711e85676385b8d5bf538741c320100009a41 )
  byte[] payload = Tools.hexStringToByteArray
    ("0100000004203107c7bd5e6b3df3e0295d8d0f1b6a978edbb624373660963c1cd9db133f50000000006a473044022020abc0c700b162f0936fdf211cc337475aab1bf1128396272d3fd240dd7aacef02201399da06807c44e9a844378b9b5aa12b22481192f8ff97ff26b674d8fa23c985012103dcf2ca4676ad26c62065084f52557443f20bd3798657733dac7ef82260f3d926ffffffffe51a564020381759b7cd183c3e3b4612eea89b5650bc349e8b335a698e4d3d8b000000006b483045022100c1a48fa21dd5a0572f3a79c38f45e1613303867ac9134a726c67244e07b3ba3602207baa88d9781271002f0ef7cf743c36b23907996516c96add6ef139863c8b0068012103dcf2ca4676ad26c62065084f52557443f20bd3798657733dac7ef82260f3d926ffffffff5c5b39eff2fca65c74a4eba65706bd07a6fb6a9ebe92f580466f1fd426dbd5b3000000006b483045022100a715e8ab5685edfb2bf73b9e2b9735fb790bacc8b301c1c6ae8e991eadd1262002202d1aaa86f83d7d84444a0590a4a991f4244668af298e0e486bbdcacc90f95e04012103dcf2ca4676ad26c62065084f52557443f20bd3798657733dac7ef82260f3d926ffffffffbc432a3bde714940ae4a46cef8d8eed1c31e32fc7e8bc3e83a9c62da129f57db000000006a473044022017d18356ab1505f3376a827a99c63390a5f1de06304036b555361b99e96cf12e022057e59fd7934a23d1e67081adccda03323b21f09c1573caadd5df07e5f983f878012103dcf2ca4676ad26c62065084f52557443f20bd3798657733dac7ef82260f3d926ffffffff028d352100000000001976a914677eaad53b1737c2aa8d6bcfc9d7ee71348d3b7f88ac489b3a0a000000001976a9143e0174b0297ac03e03992bb9e23405ff9ed39e8f88ac00000000");
  Transaction correctTransaction = new Transaction(MainNetParams.get(), payload);
  Transaction shuffledTransaction = shuffleTransaction(correctTransaction);
  Transaction appliedTransaction = Tools.applyBip69(shuffledTransaction);
  Assert.assertEquals(correctTransaction.getHash(), appliedTransaction.getHash());
}

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

@Test
public void raiseFeeTx() throws Exception {
  // Check basic tx serialization.
  Coin v1 = COIN;
  Transaction t1 = createFakeTx(PARAMS, v1, myAddress);
  t1.setPurpose(Purpose.RAISE_FEE);
  myWallet.receivePending(t1, null);
  Wallet wallet1 = roundTrip(myWallet);
  Transaction t1copy = wallet1.getTransaction(t1.getHash());
  assertEquals(Purpose.RAISE_FEE, t1copy.getPurpose());
}

相关文章

微信公众号

最新文章

更多

Transaction类方法