nip60: fixes, actual Cashu stuff and a wallet.Receive() method.

This commit is contained in:
fiatjaf
2025-01-27 16:33:33 -03:00
parent 3334f7a48b
commit c6747cdf44
11 changed files with 977 additions and 42 deletions
+3 -17
View File
@@ -5,32 +5,18 @@ import (
"encoding/json"
"fmt"
"github.com/elnosh/gonuts/cashu"
"github.com/nbd-wtf/go-nostr"
)
type Token struct {
Mint string `json:"mint"`
Proofs []Proof `json:"proofs"`
Mint string `json:"mint"`
Proofs cashu.Proofs `json:"proofs"`
mintedAt nostr.Timestamp
event *nostr.Event
}
type Proof struct {
ID string `json:"id"`
Amount uint32 `json:"amount"`
Secret string `json:"secret"`
C string `json:"C"`
}
func (t Token) Amount() uint32 {
var sum uint32
for _, p := range t.Proofs {
sum += p.Amount
}
return sum
}
func (t Token) toEvent(ctx context.Context, kr nostr.Keyer, walletId string, evt *nostr.Event) error {
pk, err := kr.GetPublicKey(ctx)
if err != nil {