Add keypair rotation detection and migration feature
When a user rotates their Nostr keypair in account settings, the
merchant still holds the old key. This adds:
- key_mismatch flag on MerchantConfig (runtime, not persisted) -
detected on each GET /api/v1/merchant by comparing account vs
merchant pubkey
- POST /api/v1/merchant/{id}/migrate-keys endpoint that updates
the merchant keys, republishes all stalls/products under the new
identity, and resubscribes
- Warning banner in the UI with a "Migrate Keys" button and
confirmation dialog
- update_merchant_keys() crud function
Orders and DM history are preserved since they reference customer
pubkeys. Old stall/product events on relays become orphaned.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5c38947fc6
commit
25023df8bd
5 changed files with 142 additions and 0 deletions
|
|
@ -36,6 +36,30 @@ window.app = Vue.createApp({
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
migrateKeys: async function () {
|
||||
LNbits.utils
|
||||
.confirmDialog(
|
||||
'This will update your merchant to use your current account Nostr keypair ' +
|
||||
'and republish all stalls and products under the new identity. ' +
|
||||
'Existing orders and messages are preserved. Continue?'
|
||||
)
|
||||
.onOk(async () => {
|
||||
try {
|
||||
const {data} = await LNbits.api.request(
|
||||
'POST',
|
||||
`/nostrmarket/api/v1/merchant/${this.merchant.id}/migrate-keys`,
|
||||
this.g.user.wallets[0].adminkey
|
||||
)
|
||||
this.merchant = data
|
||||
this.$q.notify({
|
||||
type: 'positive',
|
||||
message: 'Merchant keys migrated and stalls republished'
|
||||
})
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
})
|
||||
},
|
||||
toggleShowKeys: function () {
|
||||
this.showKeys = !this.showKeys
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue