Skip to content

Commit

Permalink
Merge pull request #1578 from evoskuil/master
Browse files Browse the repository at this point in the history
Align input.prevout and prevout default metadata.
  • Loading branch information
evoskuil authored Jan 4, 2025
2 parents 55e26ff + f0d93cd commit 444afb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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

0 comments on commit 444afb7

Please sign in to comment.