Skip to content

Commit

Permalink
wallet - nut-02 fees
Browse files Browse the repository at this point in the history
  • Loading branch information
elnosh committed Jul 16, 2024
1 parent c1a53ce commit a64be06
Show file tree
Hide file tree
Showing 4 changed files with 358 additions and 117 deletions.
17 changes: 17 additions & 0 deletions cashu/cashu.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,20 @@ func AmountSplit(amount uint64) []uint64 {
}
return rv
}

func Max(x, y uint64) uint64 {
if x > y {
return x
}
return y
}

func Count(amounts []uint64, amount uint64) uint {
var count uint = 0
for _, amt := range amounts {
if amt == amount {
count++
}
}
return count
}
30 changes: 17 additions & 13 deletions crypto/keyset.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,23 @@ func (kp *KeyPair) UnmarshalJSON(data []byte) error {
type KeysetsMap map[string]map[string]WalletKeyset

type WalletKeyset struct {
Id string
MintURL string
Unit string
Active bool
PublicKeys map[uint64]*secp256k1.PublicKey
Counter uint32
Id string
MintURL string
Unit string
Active bool
PublicKeys map[uint64]*secp256k1.PublicKey
Counter uint32
InputFeePpk uint
}

type WalletKeysetTemp struct {
Id string
MintURL string
Unit string
Active bool
PublicKeys map[uint64][]byte
Counter uint32
Id string
MintURL string
Unit string
Active bool
PublicKeys map[uint64][]byte
Counter uint32
InputFeePpk uint
}

func (wk *WalletKeyset) MarshalJSON() ([]byte, error) {
Expand All @@ -212,7 +214,8 @@ func (wk *WalletKeyset) MarshalJSON() ([]byte, error) {
}
return m
}(),
Counter: wk.Counter,
Counter: wk.Counter,
InputFeePpk: wk.InputFeePpk,
}

return json.Marshal(temp)
Expand All @@ -230,6 +233,7 @@ func (wk *WalletKeyset) UnmarshalJSON(data []byte) error {
wk.Unit = temp.Unit
wk.Active = temp.Active
wk.Counter = temp.Counter
wk.InputFeePpk = temp.InputFeePpk

wk.PublicKeys = make(map[uint64]*secp256k1.PublicKey)
for k, v := range temp.PublicKeys {
Expand Down
Loading

0 comments on commit a64be06

Please sign in to comment.