-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: asset lock tx v2 with basic RPC support + tests #7294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
e6d3cf2
23e2303
e4e81cf
76f8e2a
0d7586a
4b68c4c
cee787d
3f0bfe7
77af3d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,9 @@ | |
| #include <util/std23.h> | ||
|
|
||
| #include <core_io.h> | ||
| #include <key_io.h> | ||
| #include <rpc/util.h> | ||
| #include <script/standard.h> | ||
| #include <util/check.h> | ||
|
|
||
| #include <univalue.h> | ||
|
|
@@ -98,7 +100,9 @@ RPCResult CAssetLockPayload::GetJsonHelp(const std::string& key, bool optional) | |
| {RPCResult::Type::STR, "asm", "The asm"}, | ||
| {RPCResult::Type::STR_HEX, "hex", "The hex"}, | ||
| {RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"}, | ||
| }}}}}} | ||
| }}, | ||
| {RPCResult::Type::STR, "address", /*optional=*/true, "DIP-18 Platform address (version >= 2 only)"}, | ||
| }}}} | ||
|
Comment on lines
+103
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nest platform The new field is currently emitted as Suggested patch@@
{RPCResult::Type::OBJ, "scriptPubKey", "", {
{RPCResult::Type::STR, "asm", "The asm"},
{RPCResult::Type::STR_HEX, "hex", "The hex"},
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
- }},
- {RPCResult::Type::STR, "address", /*optional=*/true, "DIP-18 Platform address (version >= 2 only)"},
+ {RPCResult::Type::STR, "address", /*optional=*/true, "DIP-18 Platform address (version >= 2 only)"},
+ }},
}}}}
@@
UniValue spk(UniValue::VOBJ);
ScriptToUniv(credit_output.scriptPubKey, spk, /*include_hex=*/true, /*include_address=*/false);
- out.pushKV("scriptPubKey", spk);
if (nVersion >= 2) {
CTxDestination dest;
if (ExtractDestination(credit_output.scriptPubKey, dest)) {
if (const auto* pkh = std::get_if<PKHash>(&dest)) {
- out.pushKV("address", EncodePlatformDestination(PlatformP2PKHDestination(uint160(*pkh))));
+ spk.pushKV("address", EncodePlatformDestination(PlatformP2PKHDestination(uint160(*pkh))));
} else if (const auto* sh = std::get_if<ScriptHash>(&dest)) {
- out.pushKV("address", EncodePlatformDestination(PlatformP2SHDestination(uint160(*sh))));
+ spk.pushKV("address", EncodePlatformDestination(PlatformP2SHDestination(uint160(*sh))));
}
}
}
+ out.pushKV("scriptPubKey", spk);Also applies to: 117-128 🤖 Prompt for AI Agents |
||
| }}; | ||
| } | ||
|
|
||
|
|
@@ -112,6 +116,16 @@ UniValue CAssetLockPayload::ToJson() const | |
| UniValue spk(UniValue::VOBJ); | ||
| ScriptToUniv(credit_output.scriptPubKey, spk, /*include_hex=*/true, /*include_address=*/false); | ||
| out.pushKV("scriptPubKey", spk); | ||
| if (nVersion >= 2) { | ||
| CTxDestination dest; | ||
| if (ExtractDestination(credit_output.scriptPubKey, dest)) { | ||
| if (const auto* pkh = std::get_if<PKHash>(&dest)) { | ||
| out.pushKV("address", EncodePlatformDestination(PlatformP2PKHDestination(uint160(*pkh)))); | ||
| } else if (const auto* sh = std::get_if<ScriptHash>(&dest)) { | ||
| out.pushKV("address", EncodePlatformDestination(PlatformP2SHDestination(uint160(*sh)))); | ||
| } | ||
| } | ||
| } | ||
| outputs.push_back(out); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Require the activation flag at every call site.
Defaulting
is_v24_activetofalsemakes a missed caller silently apply pre-v24 rules instead of failing to compile. For consensus validation, I'd drop the default so new call paths must thread deployment state explicitly.Suggested change
📝 Committable suggestion
🤖 Prompt for AI Agents