Skip to content

Commit

Permalink
wallet: add Invoice and TxParams convenience constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 19, 2023
1 parent e6ceec2 commit d3ae6c7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ pub struct Invoice {
pub amount: Amount,
}

impl Invoice {
pub fn new(beneficiary: Address, amount: impl Into<Amount>) -> Invoice {
Invoice {
beneficiary,
amount: amount.into(),
}
}
pub fn with_max(beneficiary: Address) -> Invoice {
Invoice {
beneficiary,
amount: Amount::Max,
}
}
}

impl FromStr for Invoice {
type Err = InvoiceParseError;

Expand All @@ -127,6 +142,16 @@ pub struct TxParams {
pub seq_no: SeqNo,
}

impl TxParams {
pub fn with(fee: Sats) -> Self {
TxParams {
fee,
lock_time: None,
seq_no: SeqNo::from_consensus_u32(0),
}
}
}

impl<K, D: Descriptor<K>, L2: Layer2> Wallet<K, D, L2> {
pub fn construct_psbt(
&mut self,
Expand Down

0 comments on commit d3ae6c7

Please sign in to comment.