Fix: Setup a boltcard for the second time wouldn't generate new keys

This commit is contained in:
nicolas.dorier 2023-12-21 18:16:25 +09:00
parent 20512a59b3
commit c94dc87cb8
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
2 changed files with 5 additions and 1 deletions

View file

@ -2189,6 +2189,10 @@ namespace BTCPayServer.Tests
// Relink should bump Version
reg = await db.GetBoltcardRegistration(issuerKey, uid);
Assert.Equal((ppid, 0, 1), (reg.PullPaymentId, reg.Counter, reg.Version));
await db.LinkBoltcardToPullPayment(ppid, issuerKey, uid);
reg = await db.GetBoltcardRegistration(issuerKey, uid);
Assert.Equal((ppid, 0, 2), (reg.PullPaymentId, reg.Counter, reg.Version));
}
s.GoToStore(s.StoreId, StoreNavPages.PullPayments);

View file

@ -21,7 +21,7 @@ public static class BoltcardDataExtensions
string onConflict = onExisting switch
{
OnExistingBehavior.KeepVersion => "UPDATE SET ppid=excluded.ppid, version=boltcards.version",
OnExistingBehavior.UpdateVersion => "UPDATE SET ppid=excluded.ppid, version=excluded.version+1",
OnExistingBehavior.UpdateVersion => "UPDATE SET ppid=excluded.ppid, version=boltcards.version+1",
_ => throw new NotSupportedException()
};
return await conn.QueryFirstOrDefaultAsync<int>(