Commit Graph

64 Commits

Author SHA1 Message Date
SomberNight 68e6995a3c bitcoin.py: add helper func: neuter_bitcoin_address 2026-04-20 13:27:21 +00:00
SomberNight 58af1c493d fee_policy: lower min relay fee from 1 sat/byte to 0.1 s/b
- minrelayfee is still server-reported, but the clamps are changed from [1, 50] to [0.1, 50] sat/vbyte
- dynamic feerates coming from the estimator are still clamped to [1, 1500] sat/vbyte

ref https://github.com/bitcoin/bitcoin/pull/33106
2025-08-01 18:53:03 +00:00
SomberNight d8a6ed9b55 bitcoin.py: split dust_threshold from minrelayfee, make it hardcoded instead
- the dust threshold in bitcoin core is calculated with a 3 sat/vbyte feerate,
  which we were interpreting as 3*minrelayfee
- and now bitcoin core is considering changing the minrelayfee (1->0.1 s/b),
  independently from the dust threshold
  (in https://github.com/bitcoin/bitcoin/pull/33106)
2025-08-01 18:53:00 +00:00
SomberNight 57452d6cd5 lnutil: rm duplication of htlc witness script templates 2025-03-12 17:17:14 +00:00
ThomasV 840243e029 separate fee policy from config
- Wallet.make_unsigned_transaction takes a FeePolicy parameter
 - fee sliders act on a FeePolicy instead of config
 - different fee policies may be used for different purposes
 - do not detect dust outputs in lnsweep, delegate that to lnwatcher
2025-03-05 10:29:26 +01:00
SomberNight 0a093754d7 bitcoin.py: rm bip340_tagged_hash (duplicated from electrum_ecc) 2025-03-01 18:18:52 +00:00
Sander van Grieken 36efae3875 imports, whitespace 2025-02-10 14:22:50 +01:00
SomberNight 8d79726ec5 tests: rm some ecc tests (moved to electrum-ecc)
see https://github.com/spesmilo/electrum-ecc/commit/cd6bb9beb90c1683856183e39f8018c7a62e5e4e
2024-10-11 18:46:30 +00:00
ThomasV 3721f04ac8 replace electrum/ecc with electrum_ecc package 2024-10-10 15:46:00 +00:00
SomberNight a674a22155 follow-up moving some funcs from ecc.py to bitcoin.py
follow-up 2f3d89f415
2024-09-03 16:58:41 +00:00
ThomasV 2f3d89f415 prepare for separation of ecc module:
- move encrypt/sign functions elsewhere
- remove local dependencies in ecc.py, ecc_fast.py (except logging)
2024-06-17 13:05:57 +02:00
SomberNight 3a305881cc transaction.py: impl taproot key-spends
Add support for key-path-spending taproot utxos into transaction.py.

- no wallet support yet
- add some psbt, and minimal descriptor support
- preliminary work towards script-path spends
2024-06-07 10:58:26 +00:00
SomberNight 2f1095510c bitcoin.py/transaction.py: API changes: rm most hex usage
Instead of some functions operating with hex strings,
and others using bytes, this consolidates most things to use bytes.

This mainly focuses on bitcoin.py and transaction.py,
and then adapts the API usages in other files.

Notably,
- scripts,
- pubkeys,
- signatures
should be bytes in almost all places now.
2024-04-29 17:10:26 +00:00
SomberNight 4c63d8729b add sanity checks we don't sign tx including dummy addr
Somewhat a follow-up to 649ce979ab.

This adds some safety belts so we don't accidentally sign a tx that
contains a dummy address.
Specifically we check that tx does not contain output for dummy addr:
- in wallet.sign_transaction
- in network.broadcast_transaction

The second one is perhaps redundant, but I think it does not hurt.
2023-09-16 04:36:08 +00:00
ThomasV 649ce979ab send tx change to lightning 2023-09-09 14:14:43 +02:00
ThomasV 2b1199647e bitcoin.construct_script: add values parameter
(to be used in swapserver plugin)
2023-06-26 09:33:36 +02:00
SomberNight a80bef8421 follow-up descriptor.py: small clean-up 2023-03-03 16:40:45 +00:00
SomberNight f1f39f0e82 descriptors: wallet/transaction: construct intermediate osd 2023-03-01 17:53:52 +00:00
SomberNight 373db76ac9 util: kill bh2u
no longer useful, and the name is so confusing...
2023-02-17 11:43:11 +00:00
SomberNight 6a6391c6a3 bitcoin.py: (trivial) rm redundant "net=" defaults 2023-02-14 15:05:34 +00:00
SomberNight 0037053d73 bitcoin: 3x speedup for DecodeBase58Check
(compared to HEAD~2)

rewrite base_{decode,encode} based on https://github.com/keis/base58/blob/2fae7065e3446e69e5d748c767011f05eee8400e/base58/__init__.py
2022-12-23 09:14:18 +00:00
SomberNight 4f20e4a21f bitcoin: trivial speedup for DecodeBase58Check (down to ~80% time) 2022-12-23 09:14:14 +00:00
ghost43 8acda5f48d Merge pull request #7693 from benma/bb02
bitbox02: bump dependency to v6.0.0, support sending to taproot
2022-03-02 13:29:24 +00:00
Marko Bencun 01b4b35f9f bitbox02: bump dependency to v6.0.0, support sending to taproot 2022-03-02 14:14:24 +01:00
bitromortac 947693c90d check dust limits
* on channel opening we verify that the peer's dust limit is above 354
  sat, the limit for unknown segwit versions
* we constrain the allowed scriptpubkey types for channel closing
* we check that the remote's output is above the relay dust limit for
  the collaborative close case
2021-10-27 16:27:15 +02:00
krzysobo 7ea7e7cec9 bitcoin.address_to_scripthash: add net param (#7143)
closes #7141
2021-03-26 20:54:26 +00:00
ThomasV 64a931f21e Deterministic NodeID:
- use_recoverable_channel is a user setting, available
   only in standard wallets with a 'segwit' seed_type
 - if enabled, 'lightning_xprv' is derived from seed
 - otherwise, wallets use the existing 'lightning_privkey2'

Recoverable channels:
 - channel recovery data is added funding tx using an OP_RETURN
 - recovery data = 4 magic bytes + node id[0:16]
 - recovery data is chacha20 encrypted using funding_address as nonce.
   (this will allow to fund multiple channels in the same tx)

GUI:
  - whether channels are recoverable is shown in wallet info dialog.
  - if the wallet can have recoverable channels but has an old node_id,
    users are told to close their channels and restore from seed
    to have that feature.
2021-03-19 10:17:02 +01:00
SomberNight 4315fa4371 BIP-0350: use bech32m for witness version 1+ addresses
We have supported sending to any witness version since Electrum 3.0, using
addresses as specified in BIP-0173 (bech32 encoding).
BIP-0350 makes a breaking change in address encoding, and recommends using
(and using only) a new encoding (bech32m) for sending to witness version 1
and later. The address encoding for currently in use witness v0 addresses
remains the same, as in BIP-0173; following the BIP-0350 spec.

closes https://github.com/spesmilo/electrum/issues/6949

related:
https://github.com/bitcoin/bips/blob/cd3885c0fb9d140b111ff729294400ff5dcfc8e3/bip-0350.mediawiki
https://github.com/bitcoin/bitcoin/pull/20861
2021-03-17 18:11:55 +01:00
SomberNight 4c7a92f39c bitcoin: implement construct_script and use it 2020-10-24 07:49:06 +02:00
SomberNight 89bd520185 bitcoin: move construct_witness from transaction.py to bitcoin.py 2020-10-24 05:18:16 +02:00
SomberNight 9eb152ed98 keystore: improve check_password.
and add tests that exercise it

maybe fixes #4128
2020-09-11 13:42:12 +02:00
SomberNight fc39295d20 lnpeer: review safety check re channel open flow, and tweak params 2020-06-08 21:17:23 +02:00
SomberNight 66c264f613 bitcoin.py: change API of address_to_hash 2020-04-12 15:34:19 +02:00
TheCharlatan a4fe14bb82 BitBox02 Electrum plugin support
This commit adds support for the BitBox02 hardware wallet.
It supports both single and multisig for the electrum gui wallet.

To use the plugin a local installation of the BitBox02 python library is
required. It can be found on PiPy under the name 'bitbox02' and can be
installed from the bitbox02-firmware repository in the py/bitbox02
directory.

All communication to and from the BitBox02 is noise encrypted, the keys
required for this are stored in the wallet config file under the
bitbox02 key.

The BitBox02 registers a multisig configuration before allowing
transaction signing. This multisig configuration includes the threshold,
cosigner xpubs, keypath, a variable to indicate for mainnet and testnet,
and a name that the user can choose during configuration registration.
The user is asked to register the multisig configuration either during
address verification or during transaction signing.

The check the xpub of the BitBox02 for other hardware wallets, a button
is added in the wallet info dialog.

The wallet encryption key is fetched in a separate api call, requiring a
slightly tweaked override version of the wallet encryption password.
2020-04-12 15:34:37 +02:00
SomberNight 900a7631cf commands: add new cmd "getprivatekeyforpath" to export a WIF for a path
related: #6061
2020-03-31 05:50:18 +02:00
SomberNight 510399d3d2 wallet: dust limit calculation should round up (not down)
related to prev commit

closes #6035
2020-03-15 17:42:02 +01:00
SomberNight a500db371d wallet: put hard limit on minimum of relayfee: 1 sat/byte
(note that the dust limit is calculated based on the relayfee)

closes #6035
2020-03-15 01:26:26 +01:00
SomberNight 6f2cd8b4f5 Qt tx dialog: allow setting custom locktime
closes #2405
closes #1685
2020-03-01 09:14:50 +01:00
SomberNight 5f6f7da2a1 bitcoin.py: base58 address: make sure all public methods test checksum
Note: the checksum was already being checked in practically all cases, by the caller.
Moved the check here, to the lower level (but still public) method for sanity.
2019-12-08 06:56:19 +01:00
SomberNight 8cf3587aeb base_encode/base_decode: change to saner API 2019-12-08 06:19:51 +01:00
SomberNight 01f94fcf58 base_encode/base_decode: performance improvement
For example, for 50 KB of random data, and base 43,
previously,
- base_encode took ~38 seconds
- base_decode took ~270 seconds
now,
- base_encode takes ~7.5 seconds
- base_decode takes ~6 seconds
2019-12-08 06:07:01 +01:00
SomberNight 83740c1a78 psbt: implement CompactSize key types (previously single-byte types)
based on latest BIP-0174 update: bitcoin/bips#849
2019-11-07 03:27:38 +01:00
SomberNight bafe8a2fff integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
SomberNight e9a1c05d23 bitcoin.relayfee: minor clean-up 2019-09-18 22:08:19 +02:00
SomberNight b3da13420b bitcoin.py: SCRIPT-related clean-up. transaction.py: construct_witness 2019-08-20 09:03:09 +02:00
SomberNight 98f46dbaf5 implement script_num_to_hex. fix encoding of argument for CSV in make_commitment 2019-08-20 09:03:09 +02:00
SomberNight 8390da9b7b bitcoin.py: dedupe pubkeyhash_to_p2pkh_script 2019-07-31 01:18:51 +02:00
SomberNight 7584cebbe3 bitcoin: stricter check on WIF for compressed pubkeys
fixes #5290
2019-04-25 14:35:16 +02:00
SomberNight d4a2e9634f bitcoin: disallow importing/sweeping segwit scripts with uncompressed pubkey
fixes #4638
2019-04-19 00:37:28 +02:00
SomberNight a1d98d4331 sweep/import key: show error in Qt GUI to user as tooltip 2019-04-19 00:15:45 +02:00