Merge pull request #559 from thesimplekid/fix_multi_mint_token_check

fix: multi mint check
This commit is contained in:
thesimplekid
2025-01-24 11:35:26 +00:00
committed by GitHub
3 changed files with 14 additions and 6 deletions

View File

@@ -32,6 +32,7 @@
* `Wallet::receive_raw` which receives raw binary tokens ([lollerfirst]).
### Fixed
* Multimint unit check when wallet receiving token ([thesimplekid])
### Removed

View File

@@ -272,6 +272,10 @@ impl TokenV3 {
mint_urls
}
pub fn is_multi_mint(&self) -> bool {
self.token.len() > 1
}
}
impl FromStr for TokenV3 {

View File

@@ -190,20 +190,23 @@ impl Wallet {
p2pk_signing_keys: &[SecretKey],
preimages: &[String],
) -> Result<Amount, Error> {
let token_data = Token::from_str(encoded_token)?;
let token = Token::from_str(encoded_token)?;
let unit = token_data.unit().unwrap_or_default();
let unit = token.unit().unwrap_or_default();
if unit != self.unit {
return Err(Error::UnitUnsupported);
}
let proofs = token_data.proofs();
if proofs.len() != 1 {
return Err(Error::MultiMintTokenNotSupported);
let proofs = token.proofs();
if let Token::TokenV3(token) = &token {
if token.is_multi_mint() {
return Err(Error::MultiMintTokenNotSupported);
}
}
if self.mint_url != token_data.mint_url()? {
if self.mint_url != token.mint_url()? {
return Err(Error::IncorrectMint);
}