mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-03 12:24:27 +01:00
complete foreign middleware hooks
This commit is contained in:
+17
-2
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user