ui/shared/src/main/java/com/squareup/subzero/shared/SubzeroUtils.java
protected static byte[] bip0143hash(
      byte[] hashPrevouts,
      byte[] hashSequence,
      byte[] hashOutputs,
      TxInput input,
      byte[] script,
      int sequence,
      int locktime) {
    MessageDigest hash = Sha256Hash.newDigest();

    // The comments below are straight from BIP 0143.
    // Double SHA256 of the serialization of:
    //     1. nVersion of the transaction (4-byte little endian)
    hashUint32LE(1, hash);

    //     2. hashPrevouts (32-byte hash)
    hash.update(hashPrevouts);

    //     3. hashSequence (32-byte hash)
    hash.update(hashSequence);

    //     4. outpoint (32-byte hash + 4-byte little endian)
    hash.update(Utils.reverseBytes(input.getPrevHashOrThrow().toByteArray()));
    hashUint32LE(input.getPrevIndexOrThrow(), hash);

    //     5. scriptCode of the input (serialized as scripts inside CTxOuts)
    hash.update(new VarInt(script.length).encode());
    hash.update(script);

    //     6. value of the output spent by this input (8-byte little endian)
    hashUint64LE(input.getAmount(), hash);

    //     7. nSequence of the input (4-byte little endian)
    hashUint32LE(sequence, hash);

    //     8. hashOutputs (32-byte hash)
    hash.update(hashOutputs);

    //     9. nLocktime of the transaction (4-byte little endian)
    hashUint32LE(locktime, hash);

    //    10. sighash type of the signature (4-byte little endian)
    hashUint32LE(Transaction.SigHash.ALL.value, hash);

    // Double SHA256:
    return hash.digest(hash.digest());
  }
/**
   * This calculates the hash for a transaction
   */
This calculates the hash for a transaction
This calculates the hash for a transaction
protected static byte[] bip0143hash(
      byte[] hashPrevouts,
      byte[] hashSequence,
      byte[] hashOutputs,
      TxInput input,
      byte[] script,
      int sequence,
      int locktime) {
    MessageDigest hash = Sha256Hash.newDigest();
    hashUint32LE(1, hash);
    hash.update(hashPrevouts);
    hash.update(hashSequence);
    hash.update(Utils.reverseBytes(input.getPrevHashOrThrow().toByteArray()));
    hashUint32LE(input.getPrevIndexOrThrow(), hash);
    hash.update(new VarInt(script.length).encode());
    hash.update(script);
    hashUint64LE(input.getAmount(), hash);
    hashUint32LE(sequence, hash);
    hash.update(hashOutputs);
    hashUint32LE(locktime, hash);
    hashUint32LE(Transaction.SigHash.ALL.value, hash);
    return hash.digest(hash.digest());
  }
protected static byte [ ] bip0143hash ( byte [ ] hashPrevouts , byte [ ] hashSequence , byte [ ] hashOutputs , TxInput input , byte [ ] script , int sequence , int locktime ) { MessageDigest hash = Sha256Hash . newDigest ( ) ; hashUint32LE ( 1 , hash ) ; hash . update ( hashPrevouts ) ; hash . update ( hashSequence ) ; hash . update ( Utils . reverseBytes ( input . getPrevHashOrThrow ( ) . toByteArray ( ) ) ) ; hashUint32LE ( input . getPrevIndexOrThrow ( ) , hash ) ; hash . update ( new VarInt ( script . length ) . encode ( ) ) ; hash . update ( script ) ; hashUint64LE ( input . getAmount ( ) , hash ) ; hashUint32LE ( sequence , hash ) ; hash . update ( hashOutputs ) ; hashUint32LE ( locktime , hash ) ; hashUint32LE ( Transaction . SigHash . ALL . value , hash ) ; return hash . digest ( hash . digest ( ) ) ; }
This calculates the hash for a transaction
This calculates the hash for a transaction
// The comments below are straight from BIP 0143. // Double SHA256 of the serialization of: //     1. nVersion of the transaction (4-byte little endian) //     2. hashPrevouts (32-byte hash) //     3. hashSequence (32-byte hash) //     4. outpoint (32-byte hash + 4-byte little endian) //     5. scriptCode of the input (serialized as scripts inside CTxOuts) //     6. value of the output spent by this input (8-byte little endian) //     7. nSequence of the input (4-byte little endian) //     8. hashOutputs (32-byte hash) //     9. nLocktime of the transaction (4-byte little endian) //    10. sighash type of the signature (4-byte little endian) // Double SHA256: