complete foreign middleware hooks

This commit is contained in:
wiesche
2026-09-02 20:24:50 +02:00
parent 2fc8d89add
commit fff7948448
3 changed files with 81 additions and 4 deletions
+17 -2
View File
@@ -35,13 +35,12 @@ pub type ForeignCheckMiddleware =
fn(ForeignCheckMiddlewareFn, Option<NodeVersionInfo>, Option<&Slate>) -> Result<(), Error>;
/// Middleware Identifiers for each function
#[non_exhaustive]
pub enum ForeignCheckMiddlewareFn {
/// check_version
CheckVersion,
/// build_coinbase
BuildCoinbase,
/// verify_slate_messages
VerifySlateMessages,
/// receive_tx
ReceiveTx,
/// contract_new
@@ -50,6 +49,8 @@ pub enum ForeignCheckMiddlewareFn {
ContractSign,
/// finalize_tx
FinalizeTx,
/// verify_payment_proof_invoice
VerifyPaymentProofInvoice,
}
/// Main interface into all wallet API functions.
@@ -457,6 +458,13 @@ where
pub fn finalize_tx(&self, slate: &Slate, post_automatically: bool) -> Result<Slate, Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
if let Some(m) = self.middleware.as_ref() {
m(
ForeignCheckMiddlewareFn::FinalizeTx,
w.w2n_client().get_version_info(),
Some(slate),
)?;
}
let post_automatically = match self.doctest_mode {
true => false,
false => post_automatically,
@@ -506,6 +514,13 @@ where
) -> Result<(), Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
if let Some(m) = self.middleware.as_ref() {
m(
ForeignCheckMiddlewareFn::VerifyPaymentProofInvoice,
w.w2n_client().get_version_info(),
None,
)?;
}
foreign::verify_payment_proof_invoice(w, recipient_address, proof)
}
}