Skip to content

Commit f6f7df3

Browse files
committed
rpc: don't use GetUTXOCoin in CDeterministicMN::ToJson()
The fallback introduced in dash#5607 for spent UTXOs also works for unspent UTXOs, no reason to leave it as fallback when it can be made primary. Also, if we did want to keep GetUTXOCoin around, it would need access to CChainState due to the refactoring due in the next commit, which is possible in its RPC invocations but isn't so readily available in Qt code, where it is also called. The fallback code has the benefit of not relying on CChainState.
1 parent 6cb8dcd commit f6f7df3

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

doc/release-notes-6078.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RPC changes
2+
-----------
3+
4+
- The following RPCs, `protx list`, `protx listdiff`, `protx info` will no longer report `collateralAddress` if the transaction index has been disabled (`txindex=0`).

src/evo/deterministicmns.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,13 @@ UniValue CDeterministicMN::ToJson() const
4949
obj.pushKV("collateralHash", collateralOutpoint.hash.ToString());
5050
obj.pushKV("collateralIndex", (int)collateralOutpoint.n);
5151

52-
CScript scriptPubKey;
53-
if (Coin coin; GetUTXOCoin(collateralOutpoint, coin)) {
54-
scriptPubKey = coin.out.scriptPubKey;
55-
} else {
56-
uint256 tmpHashBlock;
57-
CTransactionRef collateralTx = GetTransaction(/* block_index */ nullptr, /* mempool */ nullptr, collateralOutpoint.hash, Params().GetConsensus(), tmpHashBlock);
58-
scriptPubKey = collateralTx->vout[collateralOutpoint.n].scriptPubKey;
59-
}
60-
CTxDestination dest;
61-
if (ExtractDestination(scriptPubKey, dest)) {
62-
obj.pushKV("collateralAddress", EncodeDestination(dest));
52+
uint256 tmpHashBlock;
53+
CTransactionRef collateralTx = GetTransaction(/* block_index */ nullptr, /* mempool */ nullptr, collateralOutpoint.hash, Params().GetConsensus(), tmpHashBlock);
54+
if (collateralTx) {
55+
CTxDestination dest;
56+
if (ExtractDestination(collateralTx->vout[collateralOutpoint.n].scriptPubKey, dest)) {
57+
obj.pushKV("collateralAddress", EncodeDestination(dest));
58+
}
6359
}
6460

6561
obj.pushKV("operatorReward", (double)nOperatorReward / 100);

0 commit comments

Comments
 (0)