Skip to content

Commit

Permalink
check all melt responses from multimint payment
Browse files Browse the repository at this point in the history
  • Loading branch information
elnosh committed Jan 3, 2025
1 parent 87b155a commit bcf82e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Implemented [NUTs](https://github.com/cashubtc/nuts/):
- [x] [NUT-12](https://github.com/cashubtc/nuts/blob/main/12.md)
- [x] [NUT-13](https://github.com/cashubtc/nuts/blob/main/13.md)
- [x] [NUT-14](https://github.com/cashubtc/nuts/blob/main/14.md)
- [ ] [NUT-15](https://github.com/cashubtc/nuts/blob/main/15.md)
- [x] [NUT-15](https://github.com/cashubtc/nuts/blob/main/15.md)

# Installation

Expand Down
14 changes: 11 additions & 3 deletions cmd/nutw/nutw.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,21 @@ func pay(ctx *cli.Context) error {
printErr(fmt.Errorf("could not do multimint payment: %v", err))
}

for _, response := range meltResponses {
if response.State == nut05.Pending {
fmt.Println("payment is pending")
return nil
} else if response.State == nut05.Unpaid {
fmt.Println("could not do multimint payment")
return nil
}
}

if meltResponses[0].State == nut05.Paid {
fmt.Printf("Multimint payment successful! Preimage: %v\n", meltResponses[0].Preimage)
return nil
} else {
fmt.Println("could not do multimint payment")
return nil
}

} else {
printErr(errors.New("aggregate amount selected cannot be higher than invoice amount"))
}
Expand Down

0 comments on commit bcf82e3

Please sign in to comment.