From 855dfee33351d6813811ed038480961f1af53aeb Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Thu, 2 Sep 2021 17:06:07 -0400 Subject: [PATCH] Update transaction JSON to reflect daemon changes --- src/rpc/daemon_zmq.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/rpc/daemon_zmq.cpp b/src/rpc/daemon_zmq.cpp index 7a68415..7e333e9 100644 --- a/src/rpc/daemon_zmq.cpp +++ b/src/rpc/daemon_zmq.cpp @@ -27,6 +27,7 @@ #include "daemon_zmq.h" +#include #include "crypto/crypto.h" // monero/src #include "rpc/message_data_structs.h" // monero/src #include "wire/crypto.h" @@ -57,13 +58,28 @@ namespace rct static void read_bytes(wire::json_reader& source, rctSig& self) { + boost::optional> ecdhInfo; + boost::optional outPk; + boost::optional txnFee; + self.outPk.reserve(default_inputs); wire::object(source, WIRE_FIELD(type), - wire::field("encrypted", std::ref(self.ecdhInfo)), - wire::field("commitments", std::ref(self.outPk)), - wire::field("fee", std::ref(self.txnFee)) + wire::optional_field("encrypted", std::ref(ecdhInfo)), + wire::optional_field("commitments", std::ref(outPk)), + wire::optional_field("fee", std::ref(txnFee)) ); + + if (self.type != RCTTypeNull) + { + if (!ecdhInfo || !outPk || !txnFee) + WIRE_DLOG_THROW(wire::error::schema::missing_key, "Expected fields `encrypted`, `commitments`, and `fee`"); + self.ecdhInfo = std::move(*ecdhInfo); + self.outPk = std::move(*outPk); + self.txnFee = std::move(*txnFee); + } + else if (ecdhInfo || outPk || txnFee) + WIRE_DLOG_THROW(wire::error::schema::invalid_key, "Did not expected `encrypted`, `commitments`, or `fee`"); } } // rct