nip57 and nip61: parse amount.
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"fiatjaf.com/nostr"
|
||||
"fiatjaf.com/nostr/nip60"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/elnosh/gonuts/cashu"
|
||||
)
|
||||
|
||||
var NutzapsNotAccepted = errors.New("user doesn't accept nutzaps")
|
||||
@@ -161,3 +162,17 @@ func getEligibleTokensWeHave(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func GetAmountFromNutzap(evt nostr.Event) uint64 {
|
||||
var total uint64
|
||||
for _, tag := range evt.Tags {
|
||||
if len(tag) >= 2 && tag[0] == "proof" {
|
||||
var proof cashu.Proof
|
||||
if err := json.Unmarshal([]byte(tag[1]), &proof); err != nil {
|
||||
continue
|
||||
}
|
||||
total += proof.Amount
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user