Skip to content

Commit

Permalink
Fix MNB Serialization for ADDRv2 in RPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquid369 authored Jul 6, 2023
1 parent 62d7459 commit afd0c73
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,11 @@ void RelayMNB(CMasternodeBroadcast& mnb, const bool fSucces)

void SerializeMNB(UniValue& statusObjRet, const CMasternodeBroadcast& mnb, const bool fSuccess, int& successful, int& failed)
{
bool isBIP155 = PROTOCOL_VERSION >= MIN_BIP155_PROTOCOL_VERSION;
int version = isBIP155 ? PROTOCOL_VERSION | ADDRV2_FORMAT : PROTOCOL_VERSION;
if(fSuccess) {
successful++;
CDataStream ssMnb(SER_NETWORK, PROTOCOL_VERSION);
CDataStream ssMnb(SER_NETWORK, version);
ssMnb << mnb;
statusObjRet.pushKV("hex", HexStr(ssMnb));
} else {
Expand Down Expand Up @@ -880,8 +882,10 @@ bool DecodeHexMnb(CMasternodeBroadcast& mnb, std::string strHexMnb) {
if (!IsHex(strHexMnb))
return false;

bool isBIP155 = PROTOCOL_VERSION >= MIN_BIP155_PROTOCOL_VERSION;
int version = isBIP155 ? PROTOCOL_VERSION | ADDRV2_FORMAT : PROTOCOL_VERSION;
std::vector<unsigned char> mnbData(ParseHex(strHexMnb));
CDataStream ssData(mnbData, SER_NETWORK, PROTOCOL_VERSION);
CDataStream ssData(mnbData, SER_NETWORK, version);
try {
ssData >> mnb;
}
Expand Down

0 comments on commit afd0c73

Please sign in to comment.