From e5ecd74eb924af9f202c19ae673a34c968832ecf Mon Sep 17 00:00:00 2001 From: elnosh Date: Wed, 22 May 2024 12:38:43 -0500 Subject: [PATCH] mint - only check if proofs are below outputs in swap --- cashu/cashu.go | 2 +- mint/mint.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cashu/cashu.go b/cashu/cashu.go index 5417f3a..2d19e6b 100644 --- a/cashu/cashu.go +++ b/cashu/cashu.go @@ -172,7 +172,7 @@ var ( InvoiceTokensIssuedErr = Error{Detail: "tokens already issued for invoice", Code: InvoiceErrCode} ProofAlreadyUsedErr = Error{Detail: "proofs already used", Code: ProofsErrCode} InvalidProofErr = Error{Detail: "invalid proof", Code: ProofsErrCode} - AmountsDoNotMatch = Error{Detail: "amounts do not match", Code: ProofsErrCode} + InputsBelowOutputs = Error{Detail: "amount of input proofs is below amount of outputs", Code: ProofsErrCode} MeltQuoteNotExistErr = Error{Detail: "melt quote does not exist", Code: QuoteErrCode} InsufficientProofsAmount = Error{Detail: "insufficient amount in proofs", Code: ProofsErrCode} InvalidKeysetProof = Error{Detail: "proof from an invalid keyset", Code: ProofsErrCode} diff --git a/mint/mint.go b/mint/mint.go index 75e550d..886a554 100644 --- a/mint/mint.go +++ b/mint/mint.go @@ -208,8 +208,8 @@ func (m *Mint) Swap(proofs cashu.Proofs, blindedMessages cashu.BlindedMessages) blindedMessagesAmount += msg.Amount } - if proofsAmount != blindedMessagesAmount { - return nil, cashu.AmountsDoNotMatch + if proofsAmount < blindedMessagesAmount { + return nil, cashu.InputsBelowOutputs } valid, err := m.VerifyProofs(proofs) @@ -221,7 +221,7 @@ func (m *Mint) Swap(proofs cashu.Proofs, blindedMessages cashu.BlindedMessages) // by adding them to the db blindedSignatures, err := m.signBlindedMessages(blindedMessages) if err != nil { - return nil, cashu.BuildCashuError(err.Error(), cashu.StandardErrCode) + return nil, err } for _, proof := range proofs {