diff --git a/doc/release-notes-6078.md b/doc/release-notes-6078.md new file mode 100644 index 0000000000000..1350e0c36817f --- /dev/null +++ b/doc/release-notes-6078.md @@ -0,0 +1,4 @@ +RPC changes +----------- + +- The following RPCs, `protx list`, `protx listdiff`, `protx info` will no longer report `collateralAddress` if the transaction index has been disabled (`txindex=0`). diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index fc2146e22755f..b35dab60a9804 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -49,17 +49,13 @@ UniValue CDeterministicMN::ToJson() const obj.pushKV("collateralHash", collateralOutpoint.hash.ToString()); obj.pushKV("collateralIndex", (int)collateralOutpoint.n); - CScript scriptPubKey; - if (Coin coin; GetUTXOCoin(collateralOutpoint, coin)) { - scriptPubKey = coin.out.scriptPubKey; - } else { - uint256 tmpHashBlock; - CTransactionRef collateralTx = GetTransaction(/* block_index */ nullptr, /* mempool */ nullptr, collateralOutpoint.hash, Params().GetConsensus(), tmpHashBlock); - scriptPubKey = collateralTx->vout[collateralOutpoint.n].scriptPubKey; - } - CTxDestination dest; - if (ExtractDestination(scriptPubKey, dest)) { - obj.pushKV("collateralAddress", EncodeDestination(dest)); + uint256 tmpHashBlock; + CTransactionRef collateralTx = GetTransaction(/* block_index */ nullptr, /* mempool */ nullptr, collateralOutpoint.hash, Params().GetConsensus(), tmpHashBlock); + if (collateralTx) { + CTxDestination dest; + if (ExtractDestination(collateralTx->vout[collateralOutpoint.n].scriptPubKey, dest)) { + obj.pushKV("collateralAddress", EncodeDestination(dest)); + } } obj.pushKV("operatorReward", (double)nOperatorReward / 100);