Skip to content

Commit

Permalink
Add witness related constants that were removed
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-zack committed Jan 10, 2025
1 parent 338f3a5 commit 133b20a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/test/java/co/rsk/federate/BtcToRskClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
* Created by ajlopez on 6/1/2016.
*/
class BtcToRskClientTest {
private static final Sha256Hash WITNESS_RESERVED_VALUE = Sha256Hash.ZERO_HASH;
private static final int WITNESS_COMMITMENT_LENGTH = 36; // 4 bytes for header, 32 for hash
private int nhash = 0;
private ActivationConfig activationConfig;
private BridgeConstants bridgeRegTestConstants;
Expand Down Expand Up @@ -2774,15 +2776,15 @@ private Transaction getCoinbaseTransactionWithWrongWitnessCommitment() {
coinbaseTx.verify();

TransactionWitness txWitness = new TransactionWitness(1);
txWitness.setPush(0, BitcoinUtils.WITNESS_RESERVED_VALUE.getBytes());
txWitness.setPush(0, WITNESS_RESERVED_VALUE.getBytes());
coinbaseTx.getInput(0).setWitness(txWitness);

Sha256Hash witnessCommitment = Sha256Hash.wrap("0011223344556677889900112233445566778899001122334455667788990011");
String witnessCommitmentHeader = "aa21a9ed";
byte[] wrongWitnessCommitmentWithHeader = ByteUtil.merge(
new byte[]{ScriptOpCodes.OP_RETURN},
new byte[]{ScriptOpCodes.OP_PUSHDATA1},
new byte[]{BitcoinUtils.WITNESS_COMMITMENT_LENGTH},
new byte[]{WITNESS_COMMITMENT_LENGTH},
Hex.decode(witnessCommitmentHeader),
witnessCommitment.getBytes()
);
Expand Down

0 comments on commit 133b20a

Please sign in to comment.