Skip to content

Commit

Permalink
wallet: save proofs in pending state in Restore
Browse files Browse the repository at this point in the history
  • Loading branch information
elnosh committed Feb 12, 2025
1 parent 898e038 commit 62e083c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions wallet/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ func Restore(walletPath, mnemonic string, mintsToRestore []string) (uint64, erro
return 0, err
}

pendingProofs := make(cashu.Proofs, 0, len(proofStateResponse.States))

for _, proofState := range proofStateResponse.States {
// NUT-07 can also respond with witness data. Since not supporting this yet, ignore proofs that have witness
if len(proofState.Witness) > 0 {
Expand All @@ -199,11 +201,22 @@ func Restore(walletPath, mnemonic string, mintsToRestore []string) (uint64, erro
proof := proofs[proofState.Y]
proofsRestored = append(proofsRestored, proof)
}

if proofState.State == nut07.Pending {
proof := proofs[proofState.Y]
pendingProofs = append(pendingProofs, proof)
}
}
if err := db.SaveProofs(proofsRestored); err != nil {
return 0, fmt.Errorf("error saving restored proofs: %v", err)
}

if len(pendingProofs) > 0 {
if err := db.AddPendingProofs(pendingProofs); err != nil {
return 0, fmt.Errorf("error saving pending proofs: %v", err)
}
}

// save wallet keyset with latest counter moving forward for wallet
if err := db.IncrementKeysetCounter(keyset.Id, counter); err != nil {
return 0, fmt.Errorf("error incrementing keyset counter: %v", err)
Expand Down

0 comments on commit 62e083c

Please sign in to comment.