pub trait Approve: SendSync {
// Required methods
fn approve_invoice(&self, invoice: &Invoice) -> bool;
fn approve_keysend(
&self,
payment_hash: PaymentHash,
amount_msat: u64,
) -> bool;
fn approve_onchain(
&self,
tx: &Transaction,
prev_outs: &[TxOut],
unknown_indices: &[usize],
) -> bool;
// Provided methods
fn handle_proposed_invoice(
&self,
node: &Arc<Node>,
invoice: Invoice,
) -> Result<bool, Status> { ... }
fn handle_proposed_keysend(
&self,
node: &Arc<Node>,
payee: PublicKey,
payment_hash: PaymentHash,
amount_msat: u64,
) -> Result<bool, Status> { ... }
fn handle_proposed_onchain(
&self,
node: &Arc<Node>,
tx: &Transaction,
segwit_flags: &[bool],
prev_outs: &[TxOut],
uniclosekeys: &[Option<(SecretKey, Vec<Vec<u8>>)>],
opaths: &[Vec<u32>],
) -> Result<bool, Status> { ... }
}
Expand description
Control payment approval.
You should implement this to present a user interface to allow the user to approve or reject payments. An approval here is meant to override other controls, such as the node allowlist.
This can also be used for automatic approval of micropayments to arbitrary destinations
- see
VelocityApprover
.
Implement the approve_invoice
, approve_keysend
and approve_onchain
methods to
control which payments are approved.
The flow is as follows:
- TODO the node allowlist is consulted, and the payment is approved if there is a match
- if an L2 payment was previously approved, it is automatically approved again
- the approver is consulted, and the payment is rejected if false was returned
- the global node velocity control is consulted if configured, and the payment is rejected if the velocity is exceeded
- otherwise, the payment is approved
Required Methods§
Sourcefn approve_invoice(&self, invoice: &Invoice) -> bool
fn approve_invoice(&self, invoice: &Invoice) -> bool
Approve an invoice for payment
Sourcefn approve_keysend(&self, payment_hash: PaymentHash, amount_msat: u64) -> bool
fn approve_keysend(&self, payment_hash: PaymentHash, amount_msat: u64) -> bool
Approve a keysend (ad-hoc payment)
Sourcefn approve_onchain(
&self,
tx: &Transaction,
prev_outs: &[TxOut],
unknown_indices: &[usize],
) -> bool
fn approve_onchain( &self, tx: &Transaction, prev_outs: &[TxOut], unknown_indices: &[usize], ) -> bool
Approve an onchain payment to an unknown destination
tx
- the transaction to be sentprev_outs
- the previous outputs used as inputs for this txunknown_indices
is the list of tx output indices that are unknown.
Provided Methods§
Sourcefn handle_proposed_invoice(
&self,
node: &Arc<Node>,
invoice: Invoice,
) -> Result<bool, Status>
fn handle_proposed_invoice( &self, node: &Arc<Node>, invoice: Invoice, ) -> Result<bool, Status>
Checks invoice for approval and adds to the node if needed and appropriate
Sourcefn handle_proposed_keysend(
&self,
node: &Arc<Node>,
payee: PublicKey,
payment_hash: PaymentHash,
amount_msat: u64,
) -> Result<bool, Status>
fn handle_proposed_keysend( &self, node: &Arc<Node>, payee: PublicKey, payment_hash: PaymentHash, amount_msat: u64, ) -> Result<bool, Status>
Checks keysend for approval and adds to the node if needed and appropriate. The payee is not validated yet.
Sourcefn handle_proposed_onchain(
&self,
node: &Arc<Node>,
tx: &Transaction,
segwit_flags: &[bool],
prev_outs: &[TxOut],
uniclosekeys: &[Option<(SecretKey, Vec<Vec<u8>>)>],
opaths: &[Vec<u32>],
) -> Result<bool, Status>
fn handle_proposed_onchain( &self, node: &Arc<Node>, tx: &Transaction, segwit_flags: &[bool], prev_outs: &[TxOut], uniclosekeys: &[Option<(SecretKey, Vec<Vec<u8>>)>], opaths: &[Vec<u32>], ) -> Result<bool, Status>
Checks onchain payment for unknown destinations and checks approval for any such outputs. Returns Ok(false) if any unknown destinations were not approved.