Skip to content

Commit a75e9b9

Browse files
committed
Adapt to database changes in electrum scripthash.
1 parent b18e434 commit a75e9b9

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

src/protocols/electrum/protocol_electrum_scripthash.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,21 +364,19 @@ void protocol_electrum::handle_blockchain_scripthash_unsubscribe(const code& ec,
364364
array_t protocol_electrum::transform(const database::histories& ins) NOEXCEPT
365365
{
366366
// Height is set to zero or max_size_t for unconfirmed history.
367+
// to_signed() conversion is simple but sacrifices top height bit (ok).
367368
static_assert(to_signed(max_size_t) == -1 && is_max(max_size_t));
368369

369370
array_t out(ins.size());
370371
std::ranges::transform(ins, out.begin(), [](const auto& in) NOEXCEPT
371372
{
372-
const auto height = in.tx.height();
373-
const bool unconfirmed = is_min(height) || is_max(height);
374-
375373
object_t object
376374
{
377-
{ "height", to_signed(height) },
375+
{ "height", to_signed(in.tx.height()) },
378376
{ "tx_hash", encode_hash(in.tx.hash()) }
379377
};
380378

381-
if (unconfirmed)
379+
if (!in.confirmed())
382380
{
383381
// A fee of max_uint64 implies missing prevout(s). This will happen
384382
// for a block-downloaded tx queried during parallel block download
@@ -400,13 +398,13 @@ array_t protocol_electrum::transform(const database::unspents& ins) NOEXCEPT
400398
array_t out(ins.size());
401399
std::ranges::transform(ins, out.begin(), [](const auto& in) NOEXCEPT
402400
{
403-
const auto& tx = in.tx;
401+
const auto& out = in.out;
404402
return object_t
405403
{
406-
{ "tx_hash", encode_hash(tx.point().hash()) },
407-
{ "tx_pos", tx.point().index() },
404+
{ "tx_hash", encode_hash(out.point().hash()) },
405+
{ "tx_pos", out.point().index() },
408406
{ "height", in.height },
409-
{ "value", tx.value() }
407+
{ "value", out.value() }
410408
};
411409
});
412410

0 commit comments

Comments
 (0)