Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add witness related constants that were removed #375

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading