Page MenuHomePhabricator

[electrum] start using tx.txinputs() in the wallet
ClosedPublic

Authored by PiRK on Sep 21 2023, 14:35.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC1007058b637b: [electrum] start using tx.txinputs() in the wallet
Summary

Convert all callsites from Transaction.inputs() to Transaction.txinputs(). The latter is less expensive as it does not require a dict building operation with hex conversions (especially when all we are interested in is len(tx.txinputs())

Depends on D14521

Test Plan

python test_runner.py

double-click on a transaction in the history to exercise get_wallet_delta

Diff Detail

Event Timeline

PiRK requested review of this revision.Sep 21 2023, 14:35
PiRK planned changes to this revision.Sep 21 2023, 14:53

investigating a bug, not sure if related

electrum/electrumabc/wallet.py
1449

I'm not sure why these vars are deleted. Maybe as a misguided garbage-collection optimization (it won't necessarily work unless gc.collect is called explicitly, which may actually slow down the function).

Fabien requested changes to this revision.Sep 22 2023, 07:23
Fabien added a subscriber: Fabien.
Fabien added inline comments.
electrum/electrumabc/wallet.py
810

I don't understand this. Because of the to_string() I expect both get to always fail and return the default ?

1449

My guess is that it used to be a "reset to null" to prevent reusing the values in the next loop iteration

This revision now requires changes to proceed.Sep 22 2023, 07:23
PiRK requested review of this revision.Sep 22 2023, 12:25
PiRK added inline comments.
electrum/electrumabc/wallet.py
810

Wallet.txo is a dict indexed by txid (as a hex string) whose values are dicts indexed by addresses containing lists of outputs for this txid and address..

{txid: {address: [[prevout_n, amount, is_coinbase], ....], ... }, ...}

outpoint.txid.to_string() (UInt256.to_string()) from TxInput is the same as coin["prevout_hash"] from the legacy coin dict.

This revision is now accepted and ready to land.Sep 22 2023, 14:37