Skip to content

Commit 0804fc3

Browse files
committed
wallet: throw error at conflicting tx versions in pre-selected inputs
1 parent cc15522 commit 0804fc3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/wallet/spend.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ util::Result<PreSelectedInputs> FetchSelectedInputs(const CWallet& wallet, const
283283
if (input_bytes == -1) {
284284
input_bytes = CalculateMaximumSignedInputSize(txout, &wallet, &coin_control);
285285
}
286+
const CWalletTx& parent_tx = txo->GetWalletTx();
287+
if (wallet.GetTxDepthInMainChain(parent_tx) == 0) {
288+
if (parent_tx.tx->version == TRUC_VERSION && coin_control.m_version != TRUC_VERSION) {
289+
return util::Error{strprintf(_("Can't spend unconfirmed version 3 pre-selected input with a version %d tx"), coin_control.m_version)};
290+
} else if (coin_control.m_version == TRUC_VERSION && parent_tx.tx->version != TRUC_VERSION) {
291+
return util::Error{strprintf(_("Can't spend unconfirmed version %d pre-selected input with a version 3 tx"), parent_tx.tx->version)};
292+
}
293+
}
286294
} else {
287295
// The input is external. We did not find the tx in mapWallet.
288296
const auto out{coin_control.GetExternalOutput(outpoint)};

0 commit comments

Comments
 (0)