Skip to content

Conversation

felipemadero
Copy link
Contributor

Why this should be merged

This PR removes built-in Ledger hardware wallet support from AvalancheGo's wallet implementation, also delegating hash signing decisions to keychain implementations instead.
This change:

  • Simplifies the wallet signing interface by removing the dual-path signing logic (signHash vs Sign)
  • Enables keychain implementations (like CubeSigner SDK or future Ledger Go SDK) to make their own signing decisions based on transaction context
  • Reduces maintenance burden by removing direct hardware wallet integration code

How this works

The implementation removes:

  • Ledger Integration: All Ledger-specific code (utils/crypto/ledger, ledger keychain, tests, and mocks)
  • signHash Parameter: Removed from P-chain and C-chain wallet signers, eliminating the conditional signing logic
  • Dual Signing Paths: Wallets now only call Sign(unsignedBytes, ...SigningOption) with full transaction bytes and context

Keychain implementations receive the full transaction bytes along with signing context (chain alias, network ID) and can decide internally how to sign. For example:

  • A remote signing service SDK can send firm transaction information for contextual validation
  • Ledger Go SDK can hash the bytes internally if needed for hardware compatibility

How this was tested

  • Unit tests

Introduces signing options infrastructure to provide transaction
context (chain alias and network ID) to wallet signers. This enables
remote signing services to properly format addresses and validate
transactions while maintaining backward compatibility with existing
signer implementations.

Changes:
- Add SigningOptions with functional options pattern
- Update Signer interface to accept variadic SigningOption parameters
- Pass chain alias and network ID to Sign() calls in P/X/C chain wallets
- Update ledger and secp256k1 signers to accept but ignore options
Extends C-chain signer to accept and pass networkID parameter,
completing the signing options infrastructure across all chains
(P, X, and C).
Removes ledger hardware wallet support and the signHash parameter
from wallet signers.

Removed:
- Ledger keychain implementation and related types
- signHash parameter from P-chain and C-chain signers
- utils/crypto/ledger package
- Ledger-related tests and mocks
- Ledger dependencies from go.mod
@felipemadero felipemadero changed the base branch from wallet-signing-improvements to master October 15, 2025 23:41
The SigningOptions type and related functions (WithChainAlias, WithNetworkID)
have been removed. The Signer.Sign() method no longer accepts signing options
as the chain alias and network ID context are not needed for the actual
signing operation.

Changes:
- Remove variadic SigningOption parameter from Signer.Sign() interface
- Remove networkID field from all signer implementations (C/P/X chains)
- Update all signer constructors to not accept networkID parameter
- Remove WithChainAlias and WithNetworkID function calls
- Update test files to use new signer constructor signatures
@Copilot Copilot AI review requested due to automatic review settings October 15, 2025 23:53
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Removes built-in Ledger hardware wallet integration and simplifies wallet signing to always use Sign with full unsigned transaction bytes. Key changes:

  • Eliminated ledger-specific code (wrapper, keychain implementations, mocks, tests, and dependencies).
  • Removed signHash boolean path; all transactions now invoke signer.Sign(unsignedBytes).
  • Updated keychain comments but retained SignHash in the Signer interface without internal use.

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
wallet/chain/p/signer/visitor.go Removed signHash parameter usage; all P-chain transactions now call sign(tx, txSigners).
wallet/chain/c/signer.go Simplified atomic signer to remove hash signing path; always signs full bytes.
utils/crypto/ledger/ledger_test.go Removed Ledger integration test.
utils/crypto/ledger/ledger.go Removed Ledger device wrapper implementation.
utils/crypto/keychain/mocks_generate_test.go Removed mock generation directive for Ledger.
utils/crypto/keychain/ledger.go Removed Ledger interface definition (now unused).
utils/crypto/keychain/keychainmock/ledger.go Removed generated Ledger mock.
utils/crypto/keychain/keychain_test.go Removed Ledger keychain and signer tests.
utils/crypto/keychain/keychain.go Deleted ledgerKeychain and ledgerSigner implementations; updated Signer comment.
go.mod Dropped ledger-related dependencies and added an indirect objx requirement.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// to sign a hash
// to sign a hash or transaction
type Signer interface {
SignHash([]byte) ([]byte, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants