From 236219f27c0046ec90a12887bf874f883d10d90b Mon Sep 17 00:00:00 2001 From: DHEBP <152355273+DHEBP@users.noreply.github.com> Date: Tue, 16 Jun 2026 13:13:38 -0400 Subject: [PATCH] fix(walletapi): guard TokenAdd against nil EntriesNative map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TokenAdd wrote to account.EntriesNative without a nil-guard, so on a freshly created or restored, not-yet-synced wallet (EntriesNative is populated lazily during sync) the assignment panicked with "assignment to entry in nil map". Its sibling InsertReplace already has this guard; TokenAdd was missing it. Surfaced by opening a freshly restored, unregistered wallet — common for cold-storage wallets that are unregistered until their registration is broadcast. Branched off the release-pinned commit so the fix carries no unrelated changes. --- walletapi/wallet.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/walletapi/wallet.go b/walletapi/wallet.go index 261b12ad..abac2720 100644 --- a/walletapi/wallet.go +++ b/walletapi/wallet.go @@ -153,6 +153,14 @@ func (w *Wallet_Memory) TokenAdd(scid crypto.Hash) (err error) { w.Lock() defer w.Unlock() + // Guard against a nil map on a freshly created/restored, not-yet-synced + // wallet (EntriesNative is populated lazily during sync). Without this the + // assignment below panics with "assignment to entry in nil map". Mirrors the + // guard already present in InsertReplace. + if w.account.EntriesNative == nil { + w.account.EntriesNative = map[crypto.Hash][]rpc.Entry{} + } + if _, ok := w.account.EntriesNative[scid]; !ok { w.account.EntriesNative[scid] = []rpc.Entry{} } else {