mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Merge 1c7be9ab90 into merged_master (Bitcoin PR #20286)
I hate this PR.
This commit is contained in:
commit
d39d57c704
55 changed files with 245 additions and 217 deletions
|
|
@ -185,10 +185,11 @@ void ScriptToUniv(const CScript& script, UniValue& out, bool include_address)
|
|||
}
|
||||
|
||||
// ELEMENTS:
|
||||
static void SidechainScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex, bool is_parent_chain)
|
||||
static void SidechainScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex, bool include_addresses, bool is_parent_chain)
|
||||
{
|
||||
const std::string prefix = is_parent_chain ? "pegout_" : "";
|
||||
TxoutType type;
|
||||
CTxDestination address;
|
||||
std::vector<CTxDestination> addresses;
|
||||
int nRequired;
|
||||
|
||||
|
|
@ -201,36 +202,47 @@ static void SidechainScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& o
|
|||
return;
|
||||
}
|
||||
|
||||
out.pushKV(prefix + "reqSigs", nRequired);
|
||||
out.pushKV(prefix + "type", GetTxnOutputType(type));
|
||||
|
||||
UniValue a(UniValue::VARR);
|
||||
if (is_parent_chain) {
|
||||
for (const CTxDestination& addr : addresses) {
|
||||
a.push_back(EncodeParentDestination(addr));
|
||||
}
|
||||
} else {
|
||||
for (const CTxDestination& addr : addresses) {
|
||||
a.push_back(EncodeDestination(addr));
|
||||
if (ExtractDestination(scriptPubKey, address)) {
|
||||
if (is_parent_chain) {
|
||||
out.pushKV(prefix + "address", EncodeParentDestination(address));
|
||||
} else {
|
||||
out.pushKV(prefix + "address", EncodeDestination(address));
|
||||
}
|
||||
}
|
||||
out.pushKV(prefix + "addresses", a);
|
||||
out.pushKV(prefix + "type", GetTxnOutputType(type));
|
||||
|
||||
if (include_addresses) {
|
||||
UniValue a(UniValue::VARR);
|
||||
if (is_parent_chain) {
|
||||
for (const CTxDestination& addr : addresses) {
|
||||
a.push_back(EncodeParentDestination(addr));
|
||||
}
|
||||
} else {
|
||||
for (const CTxDestination& addr : addresses) {
|
||||
a.push_back(EncodeDestination(addr));
|
||||
}
|
||||
}
|
||||
out.pushKV(prefix + "addresses", a);
|
||||
out.pushKV(prefix + "reqSigs", nRequired);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: from v23 ("addresses" and "reqSigs" deprecated) this method should be refactored to remove the `include_addresses` option
|
||||
// this method can also be combined with `ScriptToUniv` as they will overlap
|
||||
void ScriptPubKeyToUniv(const CScript& scriptPubKey,
|
||||
UniValue& out, bool fIncludeHex)
|
||||
UniValue& out, bool fIncludeHex, bool include_addresses)
|
||||
{
|
||||
SidechainScriptPubKeyToJSON(scriptPubKey, out, fIncludeHex, false);
|
||||
SidechainScriptPubKeyToJSON(scriptPubKey, out, fIncludeHex, include_addresses, false);
|
||||
|
||||
uint256 pegout_chain;
|
||||
CScript pegout_scriptpubkey;
|
||||
if (scriptPubKey.IsPegoutScript(pegout_chain, pegout_scriptpubkey)) {
|
||||
out.pushKV("pegout_chain", pegout_chain.GetHex());
|
||||
SidechainScriptPubKeyToJSON(pegout_scriptpubkey, out, fIncludeHex, true);
|
||||
SidechainScriptPubKeyToJSON(pegout_scriptpubkey, out, fIncludeHex, include_addresses, true);
|
||||
}
|
||||
}
|
||||
|
||||
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, int serialize_flags, const CTxUndo* txundo)
|
||||
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_addresses, UniValue& entry, bool include_hex, int serialize_flags, const CTxUndo* txundo)
|
||||
{
|
||||
entry.pushKV("txid", tx.GetHash().GetHex());
|
||||
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
|
||||
|
|
@ -374,7 +386,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
|
|||
out.pushKV("n", (int64_t)i);
|
||||
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptPubKeyToUniv(txout.scriptPubKey, o, true);
|
||||
ScriptPubKeyToUniv(txout.scriptPubKey, o, true, include_addresses);
|
||||
out.pushKV("scriptPubKey", o);
|
||||
vout.push_back(out);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue