refactor(ax): clarify ring and wallet names
Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
3686a82b33
commit
c787990b9a
3 changed files with 20 additions and 20 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue