View in context in the libbitcoin Slack #general mirror.
bool input::is_locked(size_t block_height, uint32_t median_time_past) const
{
if ((sequence_ & relative_locktime_disabled) != 0)
return false;
// bip68: a minimum block-height constraint over the input's age.
const auto minimum = (sequence_ & relative_locktime_mask);
const auto& prevout = previous_output_.metadata;
if ((sequence_ & relative_locktime_time_locked) != 0)
{
// Median time past must be monotonically-increasing by block.
BITCOIN_ASSERT(median_time_past >= prevout.median_time_past);
const auto age_seconds = median_time_past - prevout.median_time_past;
return age_seconds < (minimum << relative_locktime_seconds_shift);
}
std::cout << "bh: " << block_height << ", ph: " << prevout.height << std::endl;
if (!(block_height >= prevout.height)) {
std::cout << "IS_LOCKED block_height=" << block_height
<< " prevout = " << encode_base16(previous_output_.hash()) << ":"
<< previous_output_.index() << std::endl;
std::cout << "prevout.height: " << prevout.height << std::endl;
std::cout << std::endl << boost::stacktrace::stacktrace() << std::endl;
}
BITCOIN_ASSERT(block_height >= prevout.height);
const auto age_blocks = block_height - prevout.height;
return age_blocks < minimum;
}