2525#include < bitcoin/database/define.hpp>
2626#include < bitcoin/database/error.hpp>
2727
28+ // Consensus error codes must be system::error category in order for the node
29+ // to properly categorize the result.
30+
2831namespace libbitcoin {
2932namespace database {
3033
@@ -167,7 +170,7 @@ code CLASS::unspent_duplicates(const header_link& link,
167170 // bip30: all outputs of all previous duplicate coinbases must be spent.
168171 for (const auto & cb: coinbases)
169172 if (!is_spent_coinbase (cb))
170- return error::unspent_coinbase_collision;
173+ return system:: error::unspent_coinbase_collision;
171174
172175 return error::success;
173176}
@@ -193,7 +196,7 @@ code CLASS::unspendable(uint32_t sequence, bool coinbase,
193196 // Unassociated to block is rare, generally implies a duplicate tx.
194197 // Not strong (in any block) implies the spend is not confirmed.
195198 if (strong.is_terminal () && !is_strong (tx))
196- return error::unconfirmed_spend;
199+ return system:: error::unconfirmed_spend;
197200
198201 const auto relative = ctx.is_enabled (system::chain::flags::bip68_rule) &&
199202 transaction::is_relative_locktime_applied (coinbase, version, sequence);
@@ -207,11 +210,11 @@ code CLASS::unspendable(uint32_t sequence, bool coinbase,
207210 if (relative &&
208211 input::is_relative_locked (sequence, ctx.height , ctx.mtp ,
209212 out.height , out.mtp ))
210- return error::relative_time_locked;
213+ return system:: error::relative_time_locked;
211214
212215 if (coinbase &&
213216 !transaction::is_coinbase_mature (out.height , ctx.height ))
214- return error::coinbase_maturity;
217+ return system:: error::coinbase_maturity;
215218 }
216219
217220 return error::success;
@@ -260,7 +263,7 @@ code CLASS::populate_prevouts(point_sets& sets, size_t points,
260263 // Is any duplicated point in the block confirmed (generally empty).
261264 for (const auto & spender: cache.conflicts )
262265 if (is_strong_tx (spender))
263- return error::confirmed_double_spend;
266+ return system:: error::confirmed_double_spend;
264267
265268 // Augment spend.points with metadata.
266269 auto it = cache.spends .begin ();
0 commit comments