From ba0e64505b7bc97f9e5da3e457f89db77040e97f Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 23 Aug 2024 23:39:44 +0300 Subject: [PATCH] fix: `creditOutputs` in AssetLock tx json output should be an array of objects, not debug strings --- src/evo/assetlocktx.h | 19 ++++++++++++------- test/lint/lint-circular-dependencies.sh | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/evo/assetlocktx.h b/src/evo/assetlocktx.h index ff4853fb35..e724c6faa3 100644 --- a/src/evo/assetlocktx.h +++ b/src/evo/assetlocktx.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -51,14 +52,18 @@ public: [[nodiscard]] UniValue ToJson() const { - UniValue obj; - obj.setObject(); - obj.pushKV("version", int(nVersion)); - UniValue outputs; - outputs.setArray(); - for (const CTxOut& out : creditOutputs) { - outputs.push_back(out.ToString()); + UniValue outputs(UniValue::VARR); + for (const CTxOut& credit_output : creditOutputs) { + UniValue out(UniValue::VOBJ); + out.pushKV("value", ValueFromAmount(credit_output.nValue)); + out.pushKV("valueSat", credit_output.nValue); + UniValue spk(UniValue::VOBJ); + ScriptPubKeyToUniv(credit_output.scriptPubKey, spk, /* fIncludeHex = */ true, /* include_addresses = */ false); + out.pushKV("scriptPubKey", spk); + outputs.push_back(out); } + UniValue obj(UniValue::VOBJ); + obj.pushKV("version", int(nVersion)); obj.pushKV("creditOutputs", outputs); return obj; } diff --git a/test/lint/lint-circular-dependencies.sh b/test/lint/lint-circular-dependencies.sh index 340c97e452..88285178f5 100755 --- a/test/lint/lint-circular-dependencies.sh +++ b/test/lint/lint-circular-dependencies.sh @@ -102,6 +102,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=( "llmq/chainlocks -> net_processing -> llmq/context -> llmq/chainlocks" "coinjoin/client -> coinjoin/coinjoin -> llmq/chainlocks -> net_processing -> coinjoin/client" "rpc/blockchain -> rpc/server -> rpc/blockchain" + "core_io -> evo/assetlocktx -> core_io" ) EXIT_CODE=0