Added amount to Monero
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use rust_decimal::prelude::*;
|
||||
|
||||
pub trait CryptoInvoice {
|
||||
fn new(address: &str) -> Self;
|
||||
fn set_query_part(self, name: &str, value: &str) -> Self;
|
||||
@@ -43,3 +45,9 @@ impl CryptoInvoice for MoneroInvoice {
|
||||
format!("monero:{}{}", self.address, self.query)
|
||||
}
|
||||
}
|
||||
|
||||
impl MoneroInvoice {
|
||||
pub fn add_amount(self, amount: Decimal) -> Self {
|
||||
self.set_query_part("tx_amount", &amount.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ fn create_and_print_qr_invoice(invoice: impl CryptoInvoice) {
|
||||
|
||||
fn main() {
|
||||
let monero_donation_adress = "888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H".to_string();
|
||||
let monero_invoice = MoneroInvoice::new(&monero_donation_adress);
|
||||
let monero_invoice =
|
||||
MoneroInvoice::new(&monero_donation_adress).add_amount(Decimal::new(200, 2));
|
||||
create_and_print_qr_invoice(monero_invoice);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user