Skip to content

Commit 3f95562

Browse files
authored
Merge pull request #1750 from evoskuil/master
Modifications to script/input-witness mnemonic serialization.
2 parents 9db4387 + ceca453 commit 3f95562

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

src/chain/input.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,25 @@ DEFINE_JSON_TO_TAG(input)
501501

502502
DEFINE_JSON_FROM_TAG(input)
503503
{
504-
value =
504+
if (instance.witness().is_valid())
505505
{
506-
{ "point", value_from(instance.point()) },
507-
{ "script", value_from(instance.script()) },
508-
{ "witness", value_from(instance.witness()) },
509-
{ "sequence", instance.sequence() }
510-
};
506+
value =
507+
{
508+
{ "point", value_from(instance.point()) },
509+
{ "script", value_from(instance.script()) },
510+
{ "witness", value_from(instance.witness()) },
511+
{ "sequence", instance.sequence() }
512+
};
513+
}
514+
else
515+
{
516+
value =
517+
{
518+
{ "point", value_from(instance.point()) },
519+
{ "script", value_from(instance.script()) },
520+
{ "sequence", instance.sequence() }
521+
};
522+
}
511523
}
512524

513525
DEFINE_JSON_TO_TAG(input::cptr)

src/chain/operation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ static std::string opcode_to_prefix(opcode code,
465465
std::string operation::to_string(uint32_t active_flags) const NOEXCEPT
466466
{
467467
if (!is_valid())
468-
return "(?)";
468+
return "?";
469469

470470
if (underflow_)
471-
return "<" + encode_base16(get_data()) + ">";
471+
return "(" + encode_base16(get_data()) + ")";
472472

473473
if (data_empty())
474474
return opcode_to_mnemonic(code_, active_flags);

test/chain/operation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ BOOST_AUTO_TEST_CASE(operation__to_string__empty_underflow__empty)
781781
operation value(encoded);
782782
BOOST_REQUIRE(value.is_invalid());
783783
BOOST_REQUIRE(value.is_underflow());
784-
BOOST_REQUIRE_EQUAL(value.to_string(0), "<>");
784+
BOOST_REQUIRE_EQUAL(value.to_string(0), "()");
785785
}
786786

787787
BOOST_AUTO_TEST_CASE(operation__to_string__non_empty_underflow__empty)
@@ -791,7 +791,7 @@ BOOST_AUTO_TEST_CASE(operation__to_string__non_empty_underflow__empty)
791791
operation value(encoded);
792792
BOOST_REQUIRE(value.is_invalid());
793793
BOOST_REQUIRE(value.is_underflow());
794-
BOOST_REQUIRE_EQUAL(value.to_string(0), "<02ff>");
794+
BOOST_REQUIRE_EQUAL(value.to_string(0), "(02ff)");
795795
}
796796

797797
BOOST_AUTO_TEST_CASE(operation__to_string__nop2_no_rules__nop2)

0 commit comments

Comments
 (0)