fix: creditOutputs in AssetLock tx json output should be an array of objects, not debug strings

This commit is contained in:
UdjinM6 2024-08-23 23:39:44 +03:00
parent 045e178730
commit ba0e64505b
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9
2 changed files with 13 additions and 7 deletions

View File

@ -9,6 +9,7 @@
#include <primitives/transaction.h> #include <primitives/transaction.h>
#include <gsl/pointers.h> #include <gsl/pointers.h>
#include <core_io.h>
#include <serialize.h> #include <serialize.h>
#include <univalue.h> #include <univalue.h>
@ -51,14 +52,18 @@ public:
[[nodiscard]] UniValue ToJson() const [[nodiscard]] UniValue ToJson() const
{ {
UniValue obj; UniValue outputs(UniValue::VARR);
obj.setObject(); for (const CTxOut& credit_output : creditOutputs) {
obj.pushKV("version", int(nVersion)); UniValue out(UniValue::VOBJ);
UniValue outputs; out.pushKV("value", ValueFromAmount(credit_output.nValue));
outputs.setArray(); out.pushKV("valueSat", credit_output.nValue);
for (const CTxOut& out : creditOutputs) { UniValue spk(UniValue::VOBJ);
outputs.push_back(out.ToString()); 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); obj.pushKV("creditOutputs", outputs);
return obj; return obj;
} }

View File

@ -102,6 +102,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
"llmq/chainlocks -> net_processing -> llmq/context -> llmq/chainlocks" "llmq/chainlocks -> net_processing -> llmq/context -> llmq/chainlocks"
"coinjoin/client -> coinjoin/coinjoin -> llmq/chainlocks -> net_processing -> coinjoin/client" "coinjoin/client -> coinjoin/coinjoin -> llmq/chainlocks -> net_processing -> coinjoin/client"
"rpc/blockchain -> rpc/server -> rpc/blockchain" "rpc/blockchain -> rpc/server -> rpc/blockchain"
"core_io -> evo/assetlocktx -> core_io"
) )
EXIT_CODE=0 EXIT_CODE=0