diff --git a/tools/parser/address_writer.hpp b/tools/parser/address_writer.hpp index c1f68094..88599b14 100644 --- a/tools/parser/address_writer.hpp +++ b/tools/parser/address_writer.hpp @@ -122,14 +122,19 @@ class AddressWriter { /** Default value of ScriptDataBase.txFirstSpent is (std::numeric_limits::max()) */ bool isFirstSpend = data->txFirstSpent == std::numeric_limits::max(); + /** Can occur when a wrapped input is serialized before the top-level input */ + bool isNewerFirstSpend = txNum < data->txFirstSpent; + /** Default value of ScriptDataBase.txFirstSeen is the txNum of the transaction that contained the script */ bool isNewerFirstSeen = outputTxNum < data->txFirstSeen; if (isNewerFirstSeen) { data->txFirstSeen = outputTxNum; } - if (isFirstSpend) { + if (isNewerFirstSpend) { data->txFirstSpent = txNum; + } + if (isFirstSpend) { serializeInputImp(input, file); } }