Compare commits

..

4 Commits

8 changed files with 108 additions and 1 deletions

View File

@@ -1,3 +1,3 @@
$if2(%albumartist%,%artist%)/ $if2(%albumartist%,%artist%)/
$if(%albumartist%,$if(%date%,$replace(%date%,-,.) - )%album%/,) $if(%albumartist%,$if(%originaldate%,$replace(%originaldate%,-,.) - )%album%/,)
$if($gt(%totaldiscs%,1),$if($gt(%totaldiscs%,9),$num(%discnumber%,2),%discnumber%)-,)$if($and(%albumartist%,%tracknumber%),$num(%tracknumber%,2) ,)$if(%_multiartist%,%artist% - ,)%title% $if($gt(%totaldiscs%,1),$if($gt(%totaldiscs%,9),$num(%discnumber%,2),%discnumber%)-,)$if($and(%albumartist%,%tracknumber%),$num(%tracknumber%,2) ,)$if(%_multiartist%,%artist% - ,)%title%

14
qr_code_crypto/.gitignore vendored Normal file
View File

@@ -0,0 +1,14 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

View File

@@ -0,0 +1,8 @@
[package]
name = "qr_code_crypto"
version = "0.1.0"
edition = "2024"
[dependencies]
qrcode = { version = "0.14.1" }
rust_decimal = "1.39.0"

62
qr_code_crypto/src/lib.rs Normal file
View File

@@ -0,0 +1,62 @@
use rust_decimal::prelude::*;
pub trait CryptoInvoice {
fn new(address: &str) -> Self;
fn set_query_part(self, name: &str, value: &str) -> Self;
fn validate(self) -> bool;
fn address(self) -> String;
fn uri(self) -> String;
}
// See: https://github.com/monero-project/monero/wiki/URI-Formatting
#[derive(Clone)]
pub struct MoneroInvoice {
pub address: String,
pub query: String,
}
impl CryptoInvoice for MoneroInvoice {
fn new(address: &str) -> Self {
MoneroInvoice {
address: address.to_string(),
query: String::new(),
}
}
fn set_query_part(mut self, name: &str, value: &str) -> Self {
if self.query.is_empty() {
self.query.push('?');
}
if self.query.len() > 1 {
self.query.push('&');
}
self.query
.push_str(&format!("{}={}", name, value.replace(' ', "%20")));
self
}
fn validate(self) -> bool {
// TODO - actually do this properly - I think there's a checksum to check
// and should check the first chars are 4 or 8... and some more things
// probably only supper standard addresses too
if self.address.len() != 95 {
return false;
}
true
}
fn address(self) -> String {
self.address
}
fn uri(self) -> String {
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())
}
pub fn add_description(self, desc: &str) -> Self {
self.set_query_part("tx_description", desc)
}
}

View File

@@ -0,0 +1,23 @@
use qr_code_crypto::{CryptoInvoice, MoneroInvoice};
use qrcode::QrCode;
use qrcode::render::unicode;
use rust_decimal::prelude::*;
fn create_and_print_qr_invoice(invoice: impl CryptoInvoice) {
let code = QrCode::new(invoice.uri()).unwrap();
let image = code
.render::<unicode::Dense1x2>()
.dark_color(unicode::Dense1x2::Light)
.light_color(unicode::Dense1x2::Dark)
.build();
println!("{image}");
//println!("{}", invoice.uri());
}
fn main() {
let monero_donation_adress = "888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H".to_string();
let monero_invoice = MoneroInvoice::new(&monero_donation_adress)
.add_amount(Decimal::new(200, 2))
.add_description("Testing!");
create_and_print_qr_invoice(monero_invoice);
}

0
scryfall_deser/scripts/search_with_rofi.sh Executable file → Normal file
View File

0
scryfall_deser/scripts/search_with_rofi_with_args.sh Executable file → Normal file
View File

0
scryfall_deser/scripts/update_with_rofi.sh Executable file → Normal file
View File