Page MenuHomePhabricator

[electrum] use bytes internally for pubkeys
ClosedPublic

Authored by PiRK on Sep 6 2023, 11:13.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC36e969722c48: [electrum] use bytes internally for pubkeys
Summary

Some parts of the codebase handle pubkeys as bytes, others (most of them) expect hex strings. Bytes make more sense, as they take less memory (half) and make operations simpler and faster.

This is a first step in the effort of using bytes internally and pushing the hex string conversion closer to the UTXO representation.
To be continued.

Test Plan

python test_runner.py

Search for usages of these functions and check that they are now all called with bytes and the returned pubkey is treated as bytes.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
deser_tx
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24961
Build 49510: Build Diffelectrum-tests
Build 49509: arc lint + arc unit

Event Timeline

PiRK requested review of this revision.Sep 6 2023, 11:13
electrum/electrumabc/keystore.py
666 ↗(On Diff #42088)

this assertion is repeated in BIP32KeyStore.parse_xpubkey

PiRK planned changes to this revision.Sep 6 2023, 12:07

This is incomplete. The callsites for parse_xpubkey now receive bytes and need to be updated as well.

PiRK requested review of this revision.Sep 6 2023, 12:12

Nevermind. Its return type has not changed, it return a Base58 string.

PiRK planned changes to this revision.Sep 6 2023, 12:28

more tests are needed (signing a transaction with trezor seems to fail now)

fix the missing bytes conversion in KeyStore.get_tx_derivations, and add a test to cover this case

This revision is now accepted and ready to land.Sep 6 2023, 18:34
This revision was automatically updated to reflect the committed changes.