From a94a603f5a7cd56120a608109853514c10e227b4 Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Thu, 8 Oct 2020 15:56:35 +0200 Subject: [PATCH 1/8] Introduce rewardScript for masternodes. This adds a new field, CScript rewardScript, to the masternode data structures. For now, we just add it, return it from the RPCs, and set it to the script corresponding to the collateral pubkey on creation. We also serialise the new field as part of CMasternode, which is used e.g. in the on-disk cache, but not the wire protocol (where CMasternodeBroadcast is used instead). Thus this change invalidates the mncache format, but has no other effects on compatibility. In the future, we will implement a protocol upgrade and also network fork that will use this new field so masternodes can specify an arbitrary script to which they want to receive their payments, rather than being paid always to the collateral address. --- divi/qa/rpc-tests/masternode.py | 3 ++- divi/src/RpcMasternodeFeatures.cpp | 4 ++++ divi/src/RpcMasternodeFeatures.h | 2 ++ divi/src/masternode.cpp | 9 ++++++++- divi/src/masternode.h | 17 +++++++++++++++++ divi/src/masternodeman.cpp | 1 + divi/src/rpcmasternode.cpp | 4 +++- 7 files changed, 37 insertions(+), 3 deletions(-) diff --git a/divi/qa/rpc-tests/masternode.py b/divi/qa/rpc-tests/masternode.py index 8242cd007..9f63066d6 100644 --- a/divi/qa/rpc-tests/masternode.py +++ b/divi/qa/rpc-tests/masternode.py @@ -220,6 +220,7 @@ def find_mn(nodeIndex): assert_equal (local_status["status"], 4) assert_equal(local_status["txhash"],listedMN["txhash"]) assert_equal(local_status["outputidx"],listedMN["outidx"]) + assert_equal(local_status["rewardscript"],listedMN["rewardscript"]) node_found = True assert_equal(node_found,True) self.for_each_masternode(find_mn) @@ -237,4 +238,4 @@ def mock_wait(self,duration=1): for _ in range(duration): self.time +=1 set_node_times(self.nodes,self.time) - time.sleep(0.01) \ No newline at end of file + time.sleep(0.01) diff --git a/divi/src/RpcMasternodeFeatures.cpp b/divi/src/RpcMasternodeFeatures.cpp index 9af24ad6d..5965fa85d 100644 --- a/divi/src/RpcMasternodeFeatures.cpp +++ b/divi/src/RpcMasternodeFeatures.cpp @@ -45,6 +45,7 @@ ActiveMasternodeStatus::ActiveMasternodeStatus( , outputIndex() , netAddress() , collateralAddress() + , rewardScript() , statusCode() , statusMessage() {} @@ -54,6 +55,7 @@ MasternodeListEntry::MasternodeListEntry( , outputIndex() , status() , collateralAddress() + , rewardScript() , protocolVersion() , signatureTime() , lastSeenTime() @@ -228,6 +230,7 @@ ActiveMasternodeStatus GetActiveMasternodeStatus() result.outputIndex = std::to_string(activeMasternode.vin.prevout.n); result.netAddress = activeMasternode.service.ToString(); result.collateralAddress = CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString(); + result.rewardScript = HexStr(mn.rewardScript); result.statusCode = std::to_string(activeMasternode.status); result.statusMessage = activeMasternode.GetStatus(); result.activeMasternodeFound = true; @@ -315,6 +318,7 @@ std::vector GetMasternodeList(std::string strFilter, CBlock entry.outputIndex = oIdx; entry.status = strStatus; entry.collateralAddress = CBitcoinAddress(masternode.pubKeyCollateralAddress.GetID()).ToString(); + entry.rewardScript = HexStr(masternode.rewardScript); entry.protocolVersion = masternode.protocolVersion; entry.lastSeenTime = (int64_t)masternode.lastPing.sigTime; entry.activeTime = (int64_t)(masternode.lastPing.sigTime - masternode.sigTime); diff --git a/divi/src/RpcMasternodeFeatures.h b/divi/src/RpcMasternodeFeatures.h index cf2a610f4..87ab40395 100644 --- a/divi/src/RpcMasternodeFeatures.h +++ b/divi/src/RpcMasternodeFeatures.h @@ -20,6 +20,7 @@ struct ActiveMasternodeStatus std::string outputIndex; std::string netAddress; std::string collateralAddress; + std::string rewardScript; std::string statusCode; std::string statusMessage; ActiveMasternodeStatus(); @@ -31,6 +32,7 @@ struct MasternodeListEntry uint64_t outputIndex; std::string status; std::string collateralAddress; + std::string rewardScript; int protocolVersion; int64_t signatureTime; int64_t lastSeenTime; diff --git a/divi/src/masternode.cpp b/divi/src/masternode.cpp index c4586ab94..51c451823 100644 --- a/divi/src/masternode.cpp +++ b/divi/src/masternode.cpp @@ -6,7 +6,6 @@ #include "masternode.h" #include -#include #include #include #include