From c787990b9a649eb37b3abf390ac99544896f7b16 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 20:36:16 +0000 Subject: [PATCH] refactor(ax): clarify ring and wallet names Co-Authored-By: Charon --- chain/ring.go | 12 ++++++------ tui/explorer_model.go | 8 ++++---- wallet/scanner.go | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/chain/ring.go b/chain/ring.go index 2deb285..a423aa1 100644 --- a/chain/ring.go +++ b/chain/ring.go @@ -18,7 +18,7 @@ import ( // at the specified spending height and amount. This implements the // consensus.RingOutputsFn signature for use during signature verification. func (c *Chain) GetRingOutputs(height, amount uint64, offsets []uint64) ([]types.PublicKey, error) { - pubs := make([]types.PublicKey, len(offsets)) + publicKeys := make([]types.PublicKey, len(offsets)) for i, gidx := range offsets { txHash, outNo, err := c.GetOutput(amount, gidx) if err != nil { @@ -36,25 +36,25 @@ func (c *Chain) GetRingOutputs(height, amount uint64, offsets []uint64) ([]types switch out := tx.Vout[outNo].(type) { case types.TxOutputBare: - key, err := ringOutputKey(height, out.Target) + spendKey, err := ringOutputSpendKey(height, out.Target) if err != nil { return nil, coreerr.E("Chain.GetRingOutputs", fmt.Sprintf("ring output %d: %v", i, err), nil) } - pubs[i] = key + publicKeys[i] = spendKey default: return nil, coreerr.E("Chain.GetRingOutputs", fmt.Sprintf("ring output %d: unsupported output type %T", i, out), nil) } } - return pubs, nil + return publicKeys, nil } -// ringOutputKey extracts the spend key for a transparent output target. +// ringOutputSpendKey extracts the spend key for a transparent output target. // // TxOutMultisig does not carry enough context here to select the exact spend // path, so we return the first listed key as a deterministic fallback. // TxOutHTLC selects redeem vs refund based on whether the spending height is // before or after the contract expiration. -func ringOutputKey(height uint64, target types.TxOutTarget) (types.PublicKey, error) { +func ringOutputSpendKey(height uint64, target types.TxOutTarget) (types.PublicKey, error) { switch t := target.(type) { case types.TxOutToKey: return t.Key, nil diff --git a/tui/explorer_model.go b/tui/explorer_model.go index 2ac6b31..96c73f9 100644 --- a/tui/explorer_model.go +++ b/tui/explorer_model.go @@ -322,11 +322,11 @@ func (m *ExplorerModel) viewTxDetail() string { if len(tx.Vout) > 0 { b.WriteString("\n Outputs:\n") - for i, out := range tx.Vout { - switch v := out.(type) { + for i, output := range tx.Vout { + switch v := output.(type) { case types.TxOutputBare: - if toKey, ok := v.Target.(types.TxOutToKey); ok { - b.WriteString(fmt.Sprintf(" [%d] bare amount=%d key=%x\n", i, v.Amount, toKey.Key[:4])) + if targetKey, ok := v.Target.(types.TxOutToKey); ok { + b.WriteString(fmt.Sprintf(" [%d] bare amount=%d key=%x\n", i, v.Amount, targetKey.Key[:4])) } else { b.WriteString(fmt.Sprintf(" [%d] bare amount=%d target=%T\n", i, v.Amount, v.Target)) } diff --git a/wallet/scanner.go b/wallet/scanner.go index ea98bae..f3aee4b 100644 --- a/wallet/scanner.go +++ b/wallet/scanner.go @@ -52,33 +52,33 @@ func (s *V1Scanner) ScanTransaction(tx *types.Transaction, txHash types.Hash, isCoinbase := len(tx.Vin) > 0 && tx.Vin[0].InputType() == types.InputTypeGenesis var transfers []Transfer - for i, out := range tx.Vout { - bare, ok := out.(types.TxOutputBare) + for i, output := range tx.Vout { + bare, ok := output.(types.TxOutputBare) if !ok { continue } - expectedPub, err := crypto.DerivePublicKey( + expectedPublicKey, err := crypto.DerivePublicKey( derivation, uint64(i), [32]byte(s.account.SpendPublicKey)) if err != nil { continue } - toKey, ok := bare.Target.(types.TxOutToKey) + targetKey, ok := bare.Target.(types.TxOutToKey) if !ok { continue } - if types.PublicKey(expectedPub) != toKey.Key { + if types.PublicKey(expectedPublicKey) != targetKey.Key { continue } - ephSec, err := crypto.DeriveSecretKey( + ephemeralSecretKey, err := crypto.DeriveSecretKey( derivation, uint64(i), [32]byte(s.account.SpendSecretKey)) if err != nil { continue } - ki, err := crypto.GenerateKeyImage(expectedPub, ephSec) + keyImage, err := crypto.GenerateKeyImage(expectedPublicKey, ephemeralSecretKey) if err != nil { continue } @@ -89,10 +89,10 @@ func (s *V1Scanner) ScanTransaction(tx *types.Transaction, txHash types.Hash, Amount: bare.Amount, BlockHeight: blockHeight, EphemeralKey: KeyPair{ - Public: types.PublicKey(expectedPub), - Secret: types.SecretKey(ephSec), + Public: types.PublicKey(expectedPublicKey), + Secret: types.SecretKey(ephemeralSecretKey), }, - KeyImage: types.KeyImage(ki), + KeyImage: types.KeyImage(keyImage), Coinbase: isCoinbase, UnlockTime: extra.UnlockTime, })