Skip to content

Commit

Permalink
NetworkParameters: migrate constant BIP16_ENFORCE_TIME to Instant
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Sep 3, 2024
1 parent 0aee8a1 commit c912ee3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/main/java/org/bitcoinj/core/NetworkParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import javax.annotation.Nullable;
import java.math.BigInteger;
import java.time.Instant;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -117,7 +118,7 @@ protected NetworkParameters(Network network) {
* network rules in a soft-forking manner, that is, blocks that don't follow the rules are accepted but not
* mined upon and thus will be quickly re-orged out as long as the majority are enforcing the rule.
*/
public static final int BIP16_ENFORCE_TIME = 1333238400;
public static final Instant BIP16_ENFORCE_TIME = Instant.ofEpochSecond(1333238400);

/**
* The maximum number of coins to be generated
Expand Down Expand Up @@ -524,7 +525,7 @@ public EnumSet<Block.VerifyFlag> getBlockVerificationFlags(final Block block,
public EnumSet<Script.VerifyFlag> getTransactionVerificationFlags(final Block block,
final Transaction transaction, final VersionTally tally, final Integer height) {
final EnumSet<Script.VerifyFlag> verifyFlags = EnumSet.noneOf(Script.VerifyFlag.class);
if (block.time().getEpochSecond() >= NetworkParameters.BIP16_ENFORCE_TIME)
if (!block.time().isBefore(NetworkParameters.BIP16_ENFORCE_TIME))
verifyFlags.add(Script.VerifyFlag.P2SH);

// Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4
Expand Down

0 comments on commit c912ee3

Please sign in to comment.