|
13 | 13 | #include <streams.h> |
14 | 14 | #include <net.h> |
15 | 15 |
|
| 16 | +#include <sstream> |
| 17 | + |
16 | 18 | CAmount CMasternode::GetTierCollateralAmount(const MasternodeTier tier) |
17 | 19 | { |
18 | 20 | const auto& collateralMap = Params().MasternodeCollateralMap(); |
@@ -267,10 +269,28 @@ void CMasternodeBroadcast::Relay() const |
267 | 269 |
|
268 | 270 | std::string CMasternodeBroadcast::getMessageToSign() const |
269 | 271 | { |
270 | | - std::string vchPubKey(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end()); |
271 | | - std::string vchPubKey2(pubKeyMasternode.begin(), pubKeyMasternode.end()); |
| 272 | + std::ostringstream message; |
| 273 | + |
| 274 | + message << addr.ToString(); |
| 275 | + message << sigTime; |
| 276 | + message << std::string(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end()); |
| 277 | + |
| 278 | + /* The signature must commit also to the reward script. We do this by |
| 279 | + including it in the signed message if and only if it does not match |
| 280 | + the collateral address. This makes sure that the signature format |
| 281 | + is backwards compatible for situations where we just have the |
| 282 | + default reward script. */ |
| 283 | + if (rewardScript != GetDefaultRewardScript()) { |
| 284 | + /* Include a "marker", so that e.g. a zero-length script is different |
| 285 | + from the default situation. */ |
| 286 | + message << "rs"; |
| 287 | + message << std::string(rewardScript.begin(), rewardScript.end()); |
| 288 | + } |
| 289 | + |
| 290 | + message << std::string(pubKeyMasternode.begin(), pubKeyMasternode.end()); |
| 291 | + message << protocolVersion; |
272 | 292 |
|
273 | | - return addr.ToString() + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion); |
| 293 | + return message.str(); |
274 | 294 | } |
275 | 295 |
|
276 | 296 | uint256 CMasternodeBroadcast::GetHash() const |
|
0 commit comments