diff --git a/core/build.gradle b/core/build.gradle index 85ac5ce35..5a6f05561 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'maven-publish' apply plugin: 'jacoco' apply plugin: 'signing' -version = '20.0.0-CJ-SNAPSHOT' +version = '20.0.1-CJ-SNAPSHOT' archivesBaseName = 'dashj-core' eclipse.project.name = 'dashj-core' diff --git a/core/src/main/java/org/bitcoinj/core/Block.java b/core/src/main/java/org/bitcoinj/core/Block.java index d00b006c7..47666f505 100644 --- a/core/src/main/java/org/bitcoinj/core/Block.java +++ b/core/src/main/java/org/bitcoinj/core/Block.java @@ -269,7 +269,8 @@ public static Coin getBlockInflation(NetworkParameters params, int height, long } // Hard fork to reduce the block reward by 10 extra percent (allowing budget/superblocks) - Coin nSuperblockPart = (nPrevHeight > params.getBudgetPaymentsStartBlock()) ? nSubsidy.div(10) : Coin.ZERO; + int treasuryPart = params.isV20Active(nPrevHeight) ? 20 : 10; // parts per 100, 20 is 20% + Coin nSuperblockPart = (nPrevHeight > params.getBudgetPaymentsStartBlock()) ? nSubsidy.multiply(treasuryPart).div(100) : Coin.ZERO; return fSuperblockPartOnly ? nSuperblockPart : nSubsidy.minus(nSuperblockPart); } diff --git a/core/src/main/java/org/bitcoinj/core/VersionMessage.java b/core/src/main/java/org/bitcoinj/core/VersionMessage.java index ab2bb7833..009f6cce9 100644 --- a/core/src/main/java/org/bitcoinj/core/VersionMessage.java +++ b/core/src/main/java/org/bitcoinj/core/VersionMessage.java @@ -44,7 +44,7 @@ public class VersionMessage extends Message { /** The version of this library release, as a string. */ - public static final String BITCOINJ_VERSION = "20.0.0-CJ-SNAPSHOT"; + public static final String BITCOINJ_VERSION = "20.0.1-CJ-SNAPSHOT"; /** The value that is prepended to the subVer field of this application. */ public static final String LIBRARY_SUBVER = "/DashJ:" + BITCOINJ_VERSION + "/"; diff --git a/core/src/main/java/org/bitcoinj/evolution/AbstractQuorumState.java b/core/src/main/java/org/bitcoinj/evolution/AbstractQuorumState.java index b2380331c..313ed17e4 100644 --- a/core/src/main/java/org/bitcoinj/evolution/AbstractQuorumState.java +++ b/core/src/main/java/org/bitcoinj/evolution/AbstractQuorumState.java @@ -857,4 +857,10 @@ Sha256Hash getHashModifier(LLMQParameters llmqParams, StoredBlock quorumBaseBloc } return LLMQUtils.buildLLMQBlockHash(llmqParams.getType(), quorumBaseBlock.getHeader().getHash()); } + + public void close() { + // reset the state of any sync operation + initChainTipSyncComplete = false; + waitingForMNListDiff = false; + } } diff --git a/core/src/main/java/org/bitcoinj/evolution/SimplifiedMasternodeListEntry.java b/core/src/main/java/org/bitcoinj/evolution/SimplifiedMasternodeListEntry.java index e8ca5c0cc..fb15885e1 100644 --- a/core/src/main/java/org/bitcoinj/evolution/SimplifiedMasternodeListEntry.java +++ b/core/src/main/java/org/bitcoinj/evolution/SimplifiedMasternodeListEntry.java @@ -206,6 +206,22 @@ public Sha256Hash getConfirmedHashWithProRegTxHash() { return confirmedHashWithProRegTxHash; } + public int getType() { + return type; + } + + public boolean isHPMN() { + return type == MasternodeType.HIGHPERFORMANCE.index; + } + + public int getPlatformHTTPPort() { + return platformHTTPPort; + } + + public KeyId getPlatformNodeId() { + return platformNodeId; + } + void updateConfirmedHashWithProRegTxHash() { try { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(64); diff --git a/core/src/main/java/org/bitcoinj/evolution/SimplifiedMasternodeListManager.java b/core/src/main/java/org/bitcoinj/evolution/SimplifiedMasternodeListManager.java index f73954a37..be9c7f0a0 100644 --- a/core/src/main/java/org/bitcoinj/evolution/SimplifiedMasternodeListManager.java +++ b/core/src/main/java/org/bitcoinj/evolution/SimplifiedMasternodeListManager.java @@ -411,8 +411,8 @@ public void close() { quorumState.removeEventListeners(blockChain.getBlockChain(), peerGroup); quorumRotationState.removeEventListeners(blockChain.getBlockChain(), peerGroup); // reset state of chain sync - quorumState.initChainTipSyncComplete = false; - quorumRotationState.initChainTipSyncComplete = false; + quorumState.close(); + quorumRotationState.close(); try { threadPool.shutdown(); @@ -450,12 +450,14 @@ public boolean isQuorumRotationEnabled(LLMQParameters.LLMQType type) { return params.getLlmqDIP0024InstantSend() == type && quorumRotationActive; } - // TODO: this needs an argument for LLMQType public SimplifiedMasternodeList getListAtChainTip() { - return getMasternodeList(); + if (quorumState.getMasternodeListAtTip() != null) { + return quorumState.getMasternodeListAtTip(); + } else { + return quorumRotationState.getMnListAtH(); + } } - // TODO: this needs an argument for LLMQType public SimplifiedQuorumList getQuorumListAtTip(LLMQParameters.LLMQType llmqType) { if (!isQuorumRotationEnabled(llmqType)) { return quorumState.quorumList; diff --git a/core/src/test/java/org/bitcoinj/evolution/SimplifiedMasternodeListEntryTest.java b/core/src/test/java/org/bitcoinj/evolution/SimplifiedMasternodeListEntryTest.java index cce89bb55..126639268 100644 --- a/core/src/test/java/org/bitcoinj/evolution/SimplifiedMasternodeListEntryTest.java +++ b/core/src/test/java/org/bitcoinj/evolution/SimplifiedMasternodeListEntryTest.java @@ -38,13 +38,14 @@ public void readBytesV1Test() { byte[] smle = Utils.HEX.decode("318c32ec1598fa8f38dc76e28d15c00c20553c7020161a4c64742524a18465c39b2d789571a3b223a5365fbde69b3fe7143c4f9ebc6293afb84d340f0000000000000000000000000000ffff23a3e2204e1f08b4c1a8b9c1402ea84afe7c47f7e98d657df873b9747a0e4a497120ec62c81f314ad91a6f3384648e7e60f2734554f7f4c0fe75eec22907d6b043edb0df74ccc7b85a4500"); SimplifiedMasternodeListEntry entry = new SimplifiedMasternodeListEntry(UNITTEST, smle, 0, NetworkParameters.ProtocolVersion.BLS_LEGACY.getBitcoinProtocolVersion()); assertEquals(1, entry.version); - assertEquals(0, entry.type); + assertEquals(0, entry.getType()); assertEquals("c36584a1242574644c1a1620703c55200cc0158de276dc388ffa9815ec328c31", entry.proRegTxHash.toString()); assertEquals("000000000f344db8af9362bc9e4f3c14e73f9be6bd5f36a523b2a37195782d9b", entry.confirmedHash.toString()); assertEquals(new MasternodeAddress("35.163.226.32", 19999), entry.service); assertEquals("yidavU3B2BUNzaUv3gW6nmV4ojLNwPeazt", Address.fromPubKeyHash(UNITTEST, entry.keyIdVoting.getBytes()).toString()); assertEquals(new BLSLazyPublicKey(UNITTEST, Utils.HEX.decode("08b4c1a8b9c1402ea84afe7c47f7e98d657df873b9747a0e4a497120ec62c81f314ad91a6f3384648e7e60f2734554f7"), 0, false), entry.pubKeyOperator); assertFalse(entry.isValid); // this masternode is not valid + assertFalse(entry.isHPMN()); assertEquals(Sha256Hash.wrap("a7fc065ab65f453c4b57c597467f4d126188d5807f08cfab6b1f6d52e30e067e"), entry.getHash()); } @@ -53,13 +54,15 @@ public void readBytesV2Test() { byte[] smle = Utils.HEX.decode("0200e7aef4f585df3def44b855219ae93d6e8cc49a8c96658c5cc0813c48f5384c33e2999069d702d61d852a74b1e07d6f58101e0352d84043e866ff7946bdf5987f00000000000000000000ffff7f0000012f3197fe8172fd3207d71125a053ff32266e11110c06c1184d5be0a8118d0131d6119b138ec4d0398e7eacc5e16a75f718ed796c3a4cab668936c1f6d0945a7b97d7c0fee7cf0101002caa114755a4648d422a5caa5c915597f8c733b8e146"); SimplifiedMasternodeListEntry entry = new SimplifiedMasternodeListEntry(UNITTEST, smle, 0, NetworkParameters.ProtocolVersion.CURRENT.getBitcoinProtocolVersion()); assertEquals(2, entry.version); - assertEquals(1, entry.type); + assertEquals(1, entry.getType()); assertEquals("334c38f5483c81c05c8c65968c9ac48c6e3de99a2155b844ef3ddf85f5f4aee7", entry.proRegTxHash.toString()); assertEquals("7f98f5bd4679ff66e84340d852031e10586f7de0b1742a851dd602d7699099e2", entry.confirmedHash.toString()); assertEquals(new MasternodeAddress("127.0.0.1", 12081), entry.service); assertEquals("yXPUGD63qih1Hzgxy7gY9LFKof2KqBf3hU", Address.fromPubKeyHash(UNITTEST, entry.keyIdVoting.getBytes()).toString()); assertEquals(new BLSLazyPublicKey(UNITTEST, Utils.HEX.decode("97fe8172fd3207d71125a053ff32266e11110c06c1184d5be0a8118d0131d6119b138ec4d0398e7eacc5e16a75f718ed"), 0, false), entry.pubKeyOperator); - assertEquals(KeyId.fromString("46e1b833c7f89755915caa5c2a428d64a4554711"), entry.platformNodeId); + assertEquals(KeyId.fromString("46e1b833c7f89755915caa5c2a428d64a4554711"), entry.getPlatformNodeId()); + assertEquals(43564, entry.getPlatformHTTPPort()); + assertTrue(entry.isHPMN()); assertTrue(entry.isValid); } }