-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix transaction sign with Ledger hw #57
Conversation
WalkthroughThe recent updates in the Electrum Dash Ledger plugin focus on enhancing the Changes
Sequence Diagram(s)Refactored getTrustedInput Method: sequenceDiagram
participant Client as Ledger_Client
participant Tx as Transaction
Client->>Tx: getTrustedInput(transaction, index)
Tx-->>Client: Fetch DIP2 extra data block size limits
Client->>Tx: Adjust locktime processing
Tx-->>Client: Return trusted input
Updated sign_transaction Method: sequenceDiagram
participant Client as Ledger_Client
participant Tx as Transaction
participant Addr as constants.net.ADDRTYPE_EXP2PKH
Client->>Tx: sign_transaction(tx, password)
alt Existing address types
Client->>Tx: Process with current logic
else New address type
Client->>Addr: Check for ADDRTYPE_EXP2PKH
Addr-->>Client: Provide necessary details
end
Tx-->>Client: Transaction signed
Poem
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- electrum_dash/plugins/ledger/ledger.py (3 hunks)
Additional comments not posted (4)
electrum_dash/plugins/ledger/ledger.py (4)
140-145
: Handle DIP2 extra data block size limits correctlyThe code correctly checks if the size of the DIP2 extra data block exceeds the limit. However, consider using a constant for the limit value for better readability and maintainability.
DIP2_EXTRA_DATA_LIMIT = 255 if len(transaction.extra_data) > DIP2_EXTRA_DATA_LIMIT - len(transaction.lockTime):
290-292
: Support for additional address typeThe code now supports
constants.net.ADDRTYPE_EXP2PKH
in thesetAlternateCoinVersions
method. Ensure that this address type is correctly handled throughout the codebase.Verification successful
Support for additional address type
The code now supports
constants.net.ADDRTYPE_EXP2PKH
in thesetAlternateCoinVersions
method and includes a conditional check to handle this new address type. The new address type appears to be correctly handled in the codebase.
electrum_dash/plugins/ledger/ledger.py
: Line 290-292 and a conditional check.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new address type constants.net.ADDRTYPE_EXP2PKH is correctly handled. # Test: Search for the usage of constants.net.ADDRTYPE_EXP2PKH in the codebase. Expect: Proper handling. rg --type python 'constants.net.ADDRTYPE_EXP2PKH'Length of output: 80
Script:
#!/bin/bash # Description: Verify that the new address type constants.net.ADDRTYPE_EXP2PKH is correctly handled. # Test: Search for the usage of constants.net.ADDRTYPE_EXP2PKH in the codebase. Expect: Proper handling. rg 'constants.net.ADDRTYPE_EXP2PKH'Length of output: 309
149-152
: Ensure proper handling of APDU commandThe APDU command concatenates
lockTime
andparams
. Ensure thattransaction.lockTime
andparams
are correctly formatted and validated before this operation to prevent unexpected issues.Verification successful
Ensure proper handling of APDU command
The
transaction.lockTime
andparams
are correctly formatted and validated before concatenation into the APDU command. This is evidenced by the checks and handling within thegetTrustedInput
method, including validation oftransaction.extra_data
length and proper construction ofparams
.
electrum_dash/plugins/ledger/ledger.py
, lines around 149-152Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that transaction.lockTime and params are correctly formatted and validated. # Test: Search for the usage of transaction.lockTime and params in the codebase. Expect: Proper formatting and validation. rg --type python 'transaction.lockTime' rg --type python 'params'Length of output: 127
Script:
#!/bin/bash # Description: Verify that transaction.lockTime and params are correctly formatted and validated. # Test: Search for the usage of transaction.lockTime in the codebase. Expect: Proper formatting and validation. rg 'transaction\.lockTime' # Test: Search for the usage of params in the codebase. Expect: Proper formatting and validation. rg '\bparams\b'Length of output: 8077
Script:
#!/bin/bash # Description: Extract the relevant code blocks where transaction.lockTime and params are used to ensure they are correctly formatted and validated. # Extract lines around the usage of transaction.lockTime in the ledger.py file. rg -C 5 'transaction\.lockTime' electrum_dash/plugins/ledger/ledger.py # Extract lines around the usage of params in the ledger.py file. rg -C 5 '\bparams\b' electrum_dash/plugins/ledger/ledger.pyLength of output: 4454
525-526
: Support for additional address type in sign_transactionThe code now supports
constants.net.ADDRTYPE_EXP2PKH
in thesign_transaction
method. Ensure that this address type is correctly handled throughout the method.
Summary by CodeRabbit