コード例 #1
0
 @Override
 public String toString() {
   final ToStringHelper helper = Objects.toStringHelper(this).omitNullValues();
   helper.add("pub", Utils.HEX.encode(pub.getEncoded()));
   helper.add("chainCode", HEX.encode(chainCode));
   helper.add("path", getPathAsString());
   if (creationTimeSeconds > 0) helper.add("creationTimeSeconds", creationTimeSeconds);
   helper.add("isEncrypted", isEncrypted());
   helper.add("isPubKeyOnly", isPubKeyOnly());
   return helper.toString();
 }
コード例 #2
0
ファイル: WalletId.java プロジェクト: langerhans/multibit-hd
  /**
   * @return The wallet id as a formatted string (e.g.
   *     "66666666-77777777-88888888-99999999-aaaaaaaa")
   */
  public String toFormattedString() {

    StringBuilder buffer = new StringBuilder();

    for (int i = 0; i < walletId.length; i++) {
      buffer.append(Utils.HEX.encode(new byte[] {walletId[i]}));

      if (((i + 1) % SEPARATOR_REPEAT_PERIOD == 0) && !(i == walletId.length - 1)) {
        buffer.append(WALLET_ID_SEPARATOR);
      }
    }
    return buffer.toString();
  }
コード例 #3
0
  public static byte[] hashForSignature(
      Transaction tx, int inputIndex, byte[] connectedScript, byte sigHashType) {
    byte[] serializedSig = serializeForSignature(tx, inputIndex, connectedScript, sigHashType);

    Sha256Hash hash = Sha256Hash.twiceOf(serializedSig);
    String hashHex = Utils.HEX.encode(hash.getBytes());
    // check hash against the reference implementation inside of bitcoinj
    byte[] referenceImplementation =
        tx.hashForSignature(inputIndex, connectedScript, sigHashType).getBytes();
    String referenceImplementationHex = Utils.HEX.encode(referenceImplementation);
    if (!hashHex.equals(referenceImplementationHex)) {
      logger.error("bitcoins: " + hashHex);
      logger.error("bitcoinj: " + referenceImplementationHex);
      throw new RuntimeException(
          "Difference between BitcoinJSignatureSerialization & Actual Bitcoinj\n"
              + "bitcoin-s: "
              + hashHex
              + "\n"
              + "bitcoin-j: "
              + referenceImplementationHex);
    }
    return hash.getBytes();
  }
コード例 #4
0
 @Override
 public void formatKeyWithAddress(
     boolean includePrivateKeys, StringBuilder builder, NetworkParameters params) {
   final Address address = toAddress(params);
   builder.append("  addr:");
   builder.append(address.toString());
   builder.append("  hash160:");
   builder.append(Utils.HEX.encode(getPubKeyHash()));
   builder.append("  (");
   builder.append(getPathAsString());
   builder.append(")");
   builder.append("\n");
   if (includePrivateKeys) {
     builder.append("  ");
     builder.append(toStringWithPrivate(params));
     builder.append("\n");
   }
 }