-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
email: add subject to email notifications
- Loading branch information
Showing
3 changed files
with
64 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,25 +23,43 @@ There's configuration options for the trampoline plugin that can to be passed | |
to core lightning on startup. | ||
|
||
``` | ||
--trampoline-payment-timeout <arg> Maximum time in seconds to attempt to find a route to the destination. (default: 60) | ||
--trampoline-policy-cltv-delta <arg> Cltv expiry delta for the trampoline routing policy. Any routes where the total cltv delta is lower than this | ||
number will not be tried. (default: 1008) | ||
--trampoline-policy-fee-base <arg> The base fee to charge for every trampoline payment which passes through. (default: 0) | ||
--trampoline-email-cc <arg> 'CC' addresses for payment failure notification emails. Format [\"Satoshi Nakamoto | ||
<[email protected]>\",\"Hal Finney <[email protected]>\"] | ||
--trampoline-email-to <arg> 'To' addresses for payment failure notification emails. Format [\"Satoshi Nakamoto | ||
<[email protected]>\",\"Hal Finney <[email protected]>\"] | ||
--trampoline-cltv-delta <arg> The number of blocks between incoming payments and outgoing payments: this needs to be enough to make sure | ||
that if we have to, we can close the outgoing payment before the incoming, or redeem the incoming once the | ||
outgoing is redeemed. (default: 34) | ||
--trampoline-policy-fee-per-satoshi <arg> This is the proportional fee to charge for every trampoline payment which passes through. As percentages are | ||
too coarse, it's in millionths, so 10000 is 1%, 1000 is 0.1%. (default: 5000) | ||
--trampoline-no-self-route-hints If this flag is set, invoices where the current node is in an invoice route hint are not supported. This can | ||
be useful if there are other important plugins acting only on forwards. The trampoline plugin will 'receive' | ||
and 'pay', so has different dynamics. | ||
--trampoline-email-from <arg> 'From' address for payment failure notification emails. Format \"Satoshi Nakamoto <[email protected]>\" | ||
--trampoline-mpp-timeout <arg> Timeout in seconds before multipart htlcs that don't add up to the payment amount are failed back to the | ||
--trampoline-cltv-delta <arg> The number of blocks between incoming payments and | ||
outgoing payments: this needs to be enough to make | ||
sure that if we have to, we can close the outgoing | ||
payment before the incoming, or redeem the incoming | ||
once the outgoing is redeemed. (default: 34) | ||
--trampoline-email-cc <arg> 'CC' addresses for payment failure notification | ||
emails. Format [\"Satoshi Nakamoto | ||
<[email protected]>\",\"Hal Finney | ||
<[email protected]>\"] | ||
--trampoline-email-from <arg> 'From' address for payment failure notification | ||
emails. Format \"Satoshi Nakamoto | ||
<[email protected]>\" | ||
--trampoline-email-subject <arg> 'Subject' for payment failure notification emails. | ||
(default: Trampoline payment failure) | ||
--trampoline-policy-cltv-delta <arg> Cltv expiry delta for the trampoline routing policy. | ||
Any routes where the total cltv delta is lower than | ||
this number will not be tried. (default: 1008) | ||
--trampoline-policy-fee-base <arg> The base fee to charge for every trampoline payment | ||
which passes through. (default: 0) | ||
--trampoline-policy-fee-per-satoshi <arg> This is the proportional fee to charge for every | ||
trampoline payment which passes through. As | ||
percentages are too coarse, it's in millionths, so | ||
10000 is 1%, 1000 is 0.1%. (default: 5000) | ||
--trampoline-payment-timeout <arg> Maximum time in seconds to attempt to find a route to | ||
the destination. (default: 60) | ||
--trampoline-mpp-timeout <arg> Timeout in seconds before multipart htlcs that don't | ||
add up to the payment amount are failed back to the | ||
sender. (default: 60) | ||
--trampoline-no-self-route-hints If this flag is set, invoices where the current node | ||
is in an invoice route hint are not supported. This | ||
can be useful if there are other important plugins | ||
acting only on forwards. The trampoline plugin will | ||
'receive' and 'pay', so has different dynamics. | ||
--trampoline-email-to <arg> 'To' addresses for payment failure notification | ||
emails. Format [\"Satoshi Nakamoto | ||
<[email protected]>\",\"Hal Finney | ||
<[email protected]>\"] | ||
``` | ||
|
||
## Testing | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,10 @@ use anyhow::{anyhow, Error}; | |
use aws_sdk_sesv2::types::Destination; | ||
use block_watcher::BlockWatcher; | ||
use cln_plugin::{ | ||
options::{ConfigOption, DefaultIntegerConfigOption, FlagConfigOption, StringConfigOption}, | ||
options::{ | ||
ConfigOption, DefaultIntegerConfigOption, DefaultStringConfigOption, FlagConfigOption, | ||
StringConfigOption, | ||
}, | ||
ConfiguredPlugin, | ||
}; | ||
use email::{EmailNotificationService, EmailParams}; | ||
|
@@ -91,6 +94,11 @@ const OPTION_EMAIL_TO: StringConfigOption = ConfigOption::new_str_no_default( | |
"trampoline-email-to", | ||
"'To' addresses for payment failure notification emails. Format [\"Satoshi Nakamoto <[email protected]>\",\"Hal Finney <[email protected]>\"]", | ||
); | ||
const OPTION_EMAIL_SUBJECT: DefaultStringConfigOption = ConfigOption::new_str_with_default( | ||
"trampoline-email-subject", | ||
"Trampoline payment failure", | ||
"'Subject' for payment failure notification emails.", | ||
); | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Error> { | ||
|
@@ -104,7 +112,8 @@ async fn main() -> Result<(), Error> { | |
.option(OPTION_PAYMENT_TIMEOUT) | ||
.option(OPTION_EMAIL_CC) | ||
.option(OPTION_EMAIL_FROM) | ||
.option(OPTION_EMAIL_TO); | ||
.option(OPTION_EMAIL_TO) | ||
.option(OPTION_EMAIL_SUBJECT); | ||
|
||
let cp = match builder.configure().await? { | ||
Some(cp) => cp, | ||
|
@@ -181,6 +190,7 @@ where | |
let from: Option<String> = cp.option(&OPTION_EMAIL_FROM)?; | ||
let to: Option<String> = cp.option(&OPTION_EMAIL_TO)?; | ||
let cc: Option<String> = cp.option(&OPTION_EMAIL_CC)?; | ||
let subject: String = cp.option(&OPTION_EMAIL_SUBJECT)?; | ||
|
||
let from = match from { | ||
Some(from) => from, | ||
|
@@ -210,5 +220,9 @@ where | |
.set_cc_addresses(cc) | ||
.build(); | ||
|
||
Ok(Some(EmailParams { destination, from })) | ||
Ok(Some(EmailParams { | ||
destination, | ||
from, | ||
subject, | ||
})) | ||
} |