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 <gsl/pointers.h>
#include <core_io.h>
#include <serialize.h>
#include <univalue.h>
@ -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;
}

View File

@ -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