From 78ae279bdf3a63bb70cb7afdf71f1c59f4b37a9e Mon Sep 17 00:00:00 2001 From: wiesche Date: Mon, 17 Aug 2026 15:00:54 +0200 Subject: [PATCH] reject invalid invoice locking (#798) (cherry picked from commit 645363436d41ba621d8aa9fd536c619ee2110c5d) --- controller/tests/invoice.rs | 16 ++++++++++++++++ libwallet/src/api_impl/owner.rs | 3 +++ 2 files changed, 19 insertions(+) diff --git a/controller/tests/invoice.rs b/controller/tests/invoice.rs index 3713d5e..006d5d4 100644 --- a/controller/tests/invoice.rs +++ b/controller/tests/invoice.rs @@ -184,6 +184,22 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> { )?; assert_eq!(slate.state, SlateState::Invoice2); + wallet::controller::owner_single_use( + wallet2.clone(), + mask2, + PathBuf::from(test_dir), + |api, m| { + assert_eq!( + api.tx_lock_outputs(m, &slate), + Err(libwallet::Error::SlateState) + ); + let (_, txs) = api.retrieve_txs(m, false, None, None, None)?; + assert_eq!(txs.len(), 1); + assert_eq!(txs[0].tx_type, libwallet::TxLogEntryType::TxReceived); + Ok(()) + }, + )?; + // wallet 2 finalizes and posts wallet::controller::foreign_single_use( wallet2.clone(), diff --git a/libwallet/src/api_impl/owner.rs b/libwallet/src/api_impl/owner.rs index 638c608..44aecae 100644 --- a/libwallet/src/api_impl/owner.rs +++ b/libwallet/src/api_impl/owner.rs @@ -830,6 +830,9 @@ where K: Keychain, { let context = w.get_private_context(keychain_mask, slate.id.as_bytes())?; + if slate.state == SlateState::Invoice2 && context.input_ids.is_empty() { + return Err(Error::SlateState); + } let mut excess_override = None; let mut sl = slate.clone();