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

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

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

Transaction.getHashAsString介绍

[英]Returns the transaction hash (aka txid) as you see them in block explorers, as a hex string.
[中]以十六进制字符串的形式返回在块探索器中看到的事务哈希(也称txid)。

代码示例

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

@Override
public String toString() {
  if (!analyzed)
    return "Pending risk analysis for " + tx.getHashAsString();
  else if (nonFinal != null)
    return "Risky due to non-finality of " + nonFinal.getHashAsString();
  else if (nonStandard != null)
    return "Risky due to non-standard tx " + nonStandard.getHashAsString();
  else
    return "Non-risky";
}

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

@Override
public String toString() {
  if (!analyzed)
    return "Pending risk analysis for " + tx.getHashAsString();
  else if (nonFinal != null)
    return "Risky due to non-finality of " + nonFinal.getHashAsString();
  else if (nonStandard != null)
    return "Risky due to non-standard tx " + nonStandard.getHashAsString();
  else
    return "Non-risky";
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

/**
 * @param transaction The Bitcoinj transaction providing the information
 * @param progress    The broadcast progress of the transaction
 */
public BitcoinSendProgressEvent(Transaction transaction, double progress) {
 Preconditions.checkNotNull(transaction);
 transactionId = transaction.getHashAsString();
 this.progress = progress;
}

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

@Override
  public void run() {
    // The wallet has changed now, it'll get auto saved shortly or when the app shuts down.
    System.out.println("Sent coins onwards! Transaction hash is " + sendResult.tx.getHashAsString());
  }
}, MoreExecutors.sameThreadExecutor());

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

@Override
  public void onFailure(Throwable throwable) {
    log.error("Could not download dependencies of tx {}", tx.getHashAsString());
    log.error("Error was: ", throwable);
    // Not much more we can do at this point.
  }
});

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

@Override
  public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
    // Runs in a peer thread.
    System.out.println(tx.getHashAsString());
    latch.countDown();  // Wake up main thread.
  }
});

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

@Override
  public void onFailure(Throwable throwable) {
    log.error("Could not download dependencies of tx {}", tx.getHashAsString());
    log.error("Error was: ", throwable);
    // Not much more we can do at this point.
  }
});

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

@Override
  public void onFailure(Throwable throwable) {
    log.error("Could not download dependencies of tx {}", tx.getHashAsString());
    log.error("Error was: ", throwable);
    // Not much more we can do at this point.
  }
});

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

@Override
  public void onFailure(Throwable throwable) {
    log.error("Could not download dependencies of tx {}", tx.getHashAsString());
    log.error("Error was: ", throwable);
    // Not much more we can do at this point.
  }
});

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

@Override
  public synchronized void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) {
    System.out.println("\nReceived tx " + tx.getHashAsString());
    System.out.println(tx.toString());
  }
});

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

@Override public void onSuccess(Transaction transaction) {
  log.info("Successfully broadcast multisig contract {}. Channel now open.", transaction.getHashAsString());
  try {
    // Manually add the contract to the wallet, overriding the isRelevant checks so we can track
    // it and check for double-spends later
    wallet.receivePending(contract, null, true);
  } catch (VerificationException e) {
    throw new RuntimeException(e); // Cannot happen, we already called contract.verify()
  }
  stateMachine.transition(State.READY);
  future.set(PaymentChannelServerState.this);
}

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

@Override public void onSuccess(Transaction transaction) {
  log.info("Successfully broadcast multisig contract {}. Channel now open.", transaction.getHashAsString());
  try {
    // Manually add the contract to the wallet, overriding the isRelevant checks so we can track
    // it and check for double-spends later
    wallet.receivePending(contract, null, true);
  } catch (VerificationException e) {
    throw new RuntimeException(e); // Cannot happen, we already called contract.verify()
  }
  stateMachine.transition(State.READY);
  future.set(PaymentChannelServerState.this);
}

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

@Override public void onSuccess(Transaction transaction) {
  log.info("Successfully broadcast multisig contract {}. Channel now open.", transaction.getHashAsString());
  try {
    // Manually add the contract to the wallet, overriding the isRelevant checks so we can track
    // it and check for double-spends later
    wallet.receivePending(contract, null, true);
  } catch (VerificationException e) {
    throw new RuntimeException(e); // Cannot happen, we already called contract.verify()
  }
  stateMachine.transition(State.READY);
  future.set(PaymentChannelServerState.this);
}

代码示例来源:origin: uncleleonfan/FunWallet

@Override
public void onCoinsSent(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
  Log.d(TAG, "onCoinsSent: " + tx.getHashAsString() + "preBalance: "
      + prevBalance.getValue() + "newBalance: " + newBalance.getValue());
  updateUI(wallet);
}

代码示例来源:origin: uncleleonfan/FunWallet

@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
  Log.d(TAG, "onCoinsReceived: " + tx.getHashAsString() + "prevBalance" + prevBalance.getValue()
      + "newBalance " + newBalance.getValue());
  updateUI(wallet);
}

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

@Test
public void hashes() {
  assertEquals(TX_HASH_1, TX_1.getHashAsString());
  assertEquals(TX_HASH_2, TX_2.getHashAsString());
  assertEquals(TX_HASH_3, TX_3.getHashAsString());
}
@Test

代码示例来源:origin: openwalletGH/openwallet-android

@Test
public void hashes() {
  assertEquals(TX_HASH_1, TX_1.getHashAsString());
  assertEquals(TX_HASH_2, TX_2.getHashAsString());
  assertEquals(TX_HASH_3, TX_3.getHashAsString());
}
@Test

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

@Test
  public void cannacoinTxTest() {
    assertEquals(cannacoinHash, cannacoinTx.getHashAsString());
  }
}

代码示例来源:origin: openwalletGH/openwallet-android

@Test
  public void cannacoinTxTest() {
    assertEquals(cannacoinHash, cannacoinTx.getHashAsString());
  }
}

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

@Test
public void roundtripVersionTwoTransaction() throws Exception {
  Transaction tx = new Transaction(PARAMS, Utils.HEX.decode(
      "0200000001d7902864af9310420c6e606b814c8f89f7902d40c130594e85df2e757a7cc301070000006b483045022100ca1757afa1af85c2bb014382d9ce411e1628d2b3d478df9d5d3e9e93cb25dcdd02206c5d272b31a23baf64e82793ee5c816e2bbef251e733a638b630ff2331fc83ba0121026ac2316508287761befbd0f7495ea794b396dbc5b556bf276639f56c0bd08911feffffff0274730700000000001976a91456da2d038a098c42390c77ef163e1cc23aedf24088ac91062300000000001976a9148ebf3467b9a8d7ae7b290da719e61142793392c188ac22e00600"));
  assertEquals(tx.getVersion(), 2);
  assertEquals(tx.getHashAsString(), "0321b1413ed9048199815bd6bc2650cab1a9e8d543f109a42c769b1f18df4174");
  myWallet.addWalletTransaction(new WalletTransaction(Pool.UNSPENT, tx));
  Wallet wallet1 = roundTrip(myWallet);
  Transaction tx2 = wallet1.getTransaction(tx.getHash());
  assertEquals(checkNotNull(tx2).getVersion(), 2);
}

相关文章

微信公众号

最新文章

更多

Transaction类方法