From 0804fc3cb11089000d3b0e8bed41df0b0bf5fff1 Mon Sep 17 00:00:00 2001 From: ishaanam Date: Tue, 8 Jul 2025 15:10:00 -0400 Subject: [PATCH] wallet: throw error at conflicting tx versions in pre-selected inputs --- src/wallet/spend.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 91cdc4a894c..b65317b8e07 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -283,6 +283,14 @@ util::Result FetchSelectedInputs(const CWallet& wallet, const if (input_bytes == -1) { input_bytes = CalculateMaximumSignedInputSize(txout, &wallet, &coin_control); } + const CWalletTx& parent_tx = txo->GetWalletTx(); + if (wallet.GetTxDepthInMainChain(parent_tx) == 0) { + if (parent_tx.tx->version == TRUC_VERSION && coin_control.m_version != TRUC_VERSION) { + return util::Error{strprintf(_("Can't spend unconfirmed version 3 pre-selected input with a version %d tx"), coin_control.m_version)}; + } else if (coin_control.m_version == TRUC_VERSION && parent_tx.tx->version != TRUC_VERSION) { + return util::Error{strprintf(_("Can't spend unconfirmed version %d pre-selected input with a version 3 tx"), parent_tx.tx->version)}; + } + } } else { // The input is external. We did not find the tx in mapWallet. const auto out{coin_control.GetExternalOutput(outpoint)};