feat(wallet): token v4

feat(wallet): receive is single mint and unit
This commit is contained in:
David Caseria
2024-06-06 17:16:06 +01:00
committed by thesimplekid
parent 4637b050d6
commit 22e7c41491
14 changed files with 878 additions and 353 deletions

View File

@@ -127,7 +127,7 @@ async fn receive_token(
preimage: &[String],
) -> Result<Amount> {
let token = Token::from_str(token_str)?;
let mint_url = token.token.first().unwrap().mint.clone();
let mint_url = token.proofs().iter().next().unwrap().0.clone();
let wallet = match wallets.get(&mint_url) {
Some(wallet) => wallet.clone(),

View File

@@ -5,7 +5,7 @@ use std::str::FromStr;
use anyhow::{bail, Result};
use cdk::amount::SplitTarget;
use cdk::nuts::{Conditions, PublicKey, SpendingConditions};
use cdk::nuts::{Conditions, PublicKey, SpendingConditions, Token};
use cdk::wallet::Wallet;
use cdk::{Amount, UncheckedUrl};
use clap::Args;
@@ -32,6 +32,9 @@ pub struct SendSubCommand {
/// Refund keys that can be used after locktime
#[arg(long, action = clap::ArgAction::Append)]
refund_keys: Vec<String>,
/// Token as V3 token
#[arg(short, long)]
v3: bool,
}
pub async fn send(
@@ -152,7 +155,16 @@ pub async fn send(
)
.await?;
println!("{}", token);
match sub_command_args.v3 {
true => {
let token = Token::from_str(&token)?;
println!("{}", token.to_v3_string());
}
false => {
println!("{}", token);
}
}
Ok(())
}