Skip to content
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

Align input.prevout and prevout default metadata. #1578

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/bitcoin/system/chain/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ class BC_API input
public:
/// TODO: prevout destruct requires input destruct.
/// Public mutable metadata access, copied but not compared for equality.
/// Defaults are set so non-population issues usually imply invalidity.
mutable chain::output::cptr prevout{};
mutable chain::prevout metadata{ zero, max_uint32, false, false };
mutable chain::prevout metadata{ zero, max_uint32, true, true };
};

typedef std_vector<input> inputs;
Expand Down
3 changes: 2 additions & 1 deletion include/bitcoin/system/chain/prevout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace libbitcoin {
namespace system {
namespace chain {

// Defaults are set so non-population issues usually imply invalidity.
class BC_API prevout final
{
public:
Expand Down Expand Up @@ -74,7 +75,7 @@ class BC_API prevout final

/// The previous output is of a coinbase transaction.
/// database: populated, does not require prevout block association.
bool coinbase{ false };
bool coinbase{ true };
};

} // namespace chain
Expand Down
3 changes: 2 additions & 1 deletion test/chain/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ BOOST_AUTO_TEST_CASE(transaction__is_confirmed_double_spend__empty_inputs__false

BOOST_AUTO_TEST_CASE(transaction__is_confirmed_double_spend__default_inputs__false)
{
// input.metadata.spent defaults to true.
const accessor instance
{
0,
Expand All @@ -1350,7 +1351,7 @@ BOOST_AUTO_TEST_CASE(transaction__is_confirmed_double_spend__default_inputs__fal
0
};

BOOST_REQUIRE(!instance.is_confirmed_double_spend(42));
BOOST_REQUIRE(instance.is_confirmed_double_spend(42));
}

BOOST_AUTO_TEST_CASE(transaction__is_confirmed_double_spend__unspent_input__false)
Expand Down
Loading