162 Commits

Author SHA1 Message Date
jp1ac4
a85d4887e9
func test: allow for different bitcoin backends 2024-09-05 14:55:50 +01:00
jp1ac4
1b04b29491
func test: fix min rbf feerate
Here, the min RBF feerate is 1 more than that of the transaction
to be replaced.

The feerate of the transaction to be replaced may vary slightly
depending on the signature size and is calculated during the test.
As such, the min feerate should be set according to this
calculated value.
2024-09-05 14:55:48 +01:00
Antoine Poinsot
26ade7ebdd
qa: pipe stderr to stdout, not PIPE
It turns out that setting both to PIPE would result in stderr not being
read for some reason. So follow
https://docs.python.org/3/library/subprocess.html and set stdout to PIPE
and stderr to STDOUT.

Tested with a process (electrs) which logs on stderr.
2024-09-04 11:22:51 +02:00
Antoine Poinsot
b2aeafab56
Merge #1186: Add minimum feerate to TooLowFeerate error message
8be0d9856b29eb30593ae7614fe74430ffd206d4 commands: add minimum feerate to TooLowFeerate error message (Aaron Carlucci)

Pull request description:

  This PR adds the minimum feerate value into the `TooLowFeerate` error message for additional context. Addresses the second bullet point in #853.

ACKs for top commit:
  jp1ac4:
    ACK 8be0d9856b29eb30593ae7614fe74430ffd206d4. Thanks!

Tree-SHA512: 3a0e9c69ddb40433faf1e58c16dfee0212641b34478eddeda99388ebf82e2fb466633ab8f79c9bb0bb784f4a46807aa0a5abd65b9d92506144b84addb01dfdd8
2024-07-29 13:53:27 +02:00
Antoine Poinsot
bb68fb5ec1
Merge #1092: spend: randomized anti-fee sniping
f2791744d8ad3068d12a39bb07f3745012785a5f spend: set locktime for anti-fee sniping (jp1ac4)

Pull request description:

  This is to resolve #44.

  In the first commit, I combine the destinations and change parameters in `spend::create_spend` in order to avoid "too many arguments" error when adding a new parameter. I think these two parameters combine naturally so that `destinations` includes both recipients and change address.

  The second commit sets locktime following the same approach as Bitcoin Core:
  - locktime is set to current tip height, but randomly (about 10% of cases) value is set up to 100 blocks earlier
  - if tip is more than 8 hours old, locktime is set to 0

  For randomness, I'm currently using the current time's milliseconds in order not to add another dependency, which I think is good enough for this use case.

  For consistency, I decided to use "locktime" everywhere instead of "lock time" or "lock-time".

ACKs for top commit:
  darosior:
    ACK f2791744d8ad3068d12a39bb07f3745012785a5f

Tree-SHA512: 69a57cf664e24b32a835c35eaf9016961b2d0f396891a826582044e6302b2ca04dcf5bf2617b5e18dcbfa25cc254a6e8025262718984095677c829ce051a66cc
2024-07-29 12:32:29 +02:00
Aaron Carlucci
8be0d9856b commands: add minimum feerate to TooLowFeerate error message 2024-07-10 14:47:10 +02:00
Antoine Poinsot
168112de10
Bump version to 6.0 2024-06-27 15:53:30 +02:00
jp1ac4
0eda557fdf
descriptors: improve satisfaction size estimate for primary path
Thanks to darosior for providing the changes to `max_sat_weight`
and the Taproot sanity checks test.
2024-06-20 17:09:38 +01:00
jp1ac4
f2791744d8
spend: set locktime for anti-fee sniping 2024-05-28 07:50:48 +01:00
jp1ac4
ed86696daf
tests: remove print statements 2024-03-28 12:38:09 +00:00
jp1ac4
5d6ca97e4c
spend: reword warning messages 2024-03-28 11:08:49 +00:00
jp1ac4
8078a2791a
tests: use function to calculate additional fee
This will reduce flakiness in case the ancestor size differs due
to changes in signature size.
2024-03-28 11:03:21 +00:00
jp1ac4
deb75884bf
tests: run black 2024-03-28 11:03:15 +00:00
Antoine Poinsot
6d498db5e5
Merge #1034: Prepare v5 release
2dc8cb0d422d2f601c8662df71651c596d15ae36 README: add Coldcard as supported signing device (Antoine Poinsot)
abf15fea3c15ca5f0005417a1490e057d40e6c6b CHANGELOG: release notes for v5 (Antoine Poinsot)
b5c2375d0bb6bef6cd2f0d7534c303fe71118105 doc: update the signing devices compatibility documentation (Antoine Poinsot)
d9337121abe486389514c7b2336e39d2a1f0c8de Bump Liana version (Antoine Poinsot)
de05460ad01145df9bbf63ec58932a72dd1a14d3 doc/BUILD.md: correct MSRV (Antoine Poinsot)

Pull request description:

ACKs for top commit:
  darosior:
    self-ACK 2dc8cb0d422d2f601c8662df71651c596d15ae36 -- not code

Tree-SHA512: b84ea6dabf3ff41ac9b61c6ee8ef7cbbdb5942d13bff83b70e60c93e2f61a14db164b7987129cfde5fd59a667297e2832458f62f0e979d949667d0cc2c168f37
2024-03-25 16:33:51 +01:00
Antoine Poinsot
d9337121ab
Bump Liana version 2024-03-22 16:42:33 +01:00
jp1ac4
3a7c151674
database: allow for coinbase transactions to change addresses
`is_change` is `true` for a coin if its address is derived
from our change descriptor and could in principle be used for a
coinbase transaction.

The functional test was provided by darosior in a PR comment:
https://github.com/wizardsardine/liana/pull/1001#pullrequestreview-1948564150
2024-03-20 18:29:37 +00:00
Antoine Poinsot
4bb2372a63
qa: drop specific value assertions in coin selection test
They don't add much value and cause flakiness because the size might sometimes be lower than that due to low-R signature grinding.

Fixes #1000.
2024-03-13 19:21:54 +01:00
Antoine Poinsot
687a0c2816
qa: adapt hardcoded coin selection tests to Taproot 2024-03-13 19:21:53 +01:00
Antoine Poinsot
ecef6bff5e
qa: functional tests lianad using Taproot descriptors
We introduce Taproot support in the test framework through a global
toggle. A few modifications are made to some tests to adapt them under
Taproot (notably the hardcoded fees / amounts).

This is based on my introduction of a quick and dirty support for
TapMiniscript in my python-bip380 library:
https://github.com/darosior/python-bip380/pull/23. In addition to this i
didn't want to implement a signer in the Python test suite so here we
introduce a simple Rust program based on our "hot signer" which will
sign a PSBT with an xpriv provided through its stdin and output the
signed PSBT on its stdout. Eventually it would be nicer to have a Python
signer instead of having to call a program.

The whole test suite should pass under both Taproot and P2WSH. Only a
single test is skipped for now under Taproot since it needs a finalizer
in the test suite.

I also caught a bug in the RBF tests which i fixed in place.
2024-03-13 19:21:52 +01:00
Antoine Poinsot
8d33f49935
Merge #965: poller: unspend expired before new spend
cc1de1d6d6710f1426a957806661e7f3461a7cb5 poller: unspend coins before spending new (jp1ac4)
1e7653e08a3778446ff677bb147df68b734a31fd tests: add function to wait while condition holds (jp1ac4)

Pull request description:

  This change ensures that the spend txid of a coin is updated directly to another value in case a conflicting spend is detected.

  The previous order caused the spend txid to first be cleared, which would misleadingly make the coin appear as confirmed
  rather than spending.

  I've added a new utils function for the functional tests that is a slight generalisation of `wait_for` with an additional condition that must always be met while waiting.

  `wait_for` now calls this new function with the condition being one that is always true.

ACKs for top commit:
  darosior:
    ACK cc1de1d6d6710f1426a957806661e7f3461a7cb5

Tree-SHA512: e3f00804a63b0e94bc1b2cbee03cac63dd6e2555ca6d301589b356b2baf8e0cf27362e1dda44018d1d8282e300b187079fcf61f5d2754263b9e8b08cd34be06e
2024-03-12 08:47:41 +01:00
jp1ac4
cc1de1d6d6
poller: unspend coins before spending new
This change ensures that the spend txid of a coin is updated
directly to another value in case a conflicting spend is
detected.

The previous order caused the spend txid to first be cleared,
which would misleadingly make the coin appear as confirmed
rather than spending.
2024-03-11 15:41:17 +00:00
jp1ac4
1e7653e08a
tests: add function to wait while condition holds
This adds a new utils function that is a slight generalisation
of `wait_for` with an additional condition that must always be
met while waiting.

`wait_for` now calls this new function with the condition being
one that is always true.
2024-03-11 15:41:17 +00:00
jp1ac4
bfd6ca517b
commands: increment receive index on each use
This is a similar fix as for the change index.
2024-03-09 19:15:30 +01:00
jp1ac4
cc5e396ace
commands: increment change index on each use
This is a fix to ensure the change index in the database is
incremented if a new spend is created with a change
address derived from the current index, regardless of whether
this new spend is broadcast or not.
2024-03-09 19:15:28 +01:00
Antoine Poinsot
cf299b997b
Merge #957: Get genesis timestamp from bitcoind
f2c418f79a6fe8f1d6138b12af9fdc7303b4725d get genesis timestamp from bitcoind (pythcoiner)

Pull request description:

  fixes #904

ACKs for top commit:
  jp1ac4:
    ACK f2c418f79a.

Tree-SHA512: 7b1b7c13c21b657109ab0aab0d89deb47f5f6693f95687b86c219fc109ee304c38e3ebe865d071ebbbfa890a6a754c615f5dd70f2fe8c492bdea35d0394f36eb
2024-03-09 19:04:00 +01:00
Antoine Poinsot
1819988b3f
Merge #921: Add optional txids param to listspendtxs
da1ebce5b6328f8f5636192e7434d1ba598d5516 add txids param to listspendtxs (pythcoiner)

Pull request description:

  fix #862
  - [x] daemon
  - [x] tests
  - [x] doc

ACKs for top commit:
  jp1ac4:
    ACK da1ebce5b6.

Tree-SHA512: 9696a8077bce2ba8f2abc9eda6a4cdc8654c83ffd61bc5b8419ca50e5ecc447dc78d2059e608c16e94306c27f2aaf21a77c879d21a54f24a049337545750cef7
2024-03-09 18:55:01 +01:00
Antoine Poinsot
1fe5acb673
Merge #873: commands: include unconfirmed change as coin selection candidates
c0d432057df6b2f0bc879f718489c761867fa88c spend: add warning about fee for ancestor (jp1ac4)
a38c1739b6d6bdc5944e2300f1cdf9121babf7d1 spend: return additional fee paid for ancestors (jp1ac4)
62bb4aded43a379bcf5607fd48c492fcfb84bfd5 commands: include unconfirmed change as candidates (jp1ac4)
b05b0f14e5e08ab32e78ea263531d8a587c5b184 commands: add ancestor info for user-selected unconfirmed coins (jp1ac4)
94ef66c03a17221cc9cddb8d1d463a46f0b489c9 spend: increase candidate weight to pay for ancestor (jp1ac4)
5f0022083df8354ceb03d79311317e378296629d bitcoin: add mempool_entry to interface (jp1ac4)
edbf00f17c3796dc326bfbe6ae8833c201bdc045 bitcoin: add ancestor size and fees to mempool entry (jp1ac4)
04503225bcd066dd7d4099997c56b836c29d5b31 func test: use utils function (jp1ac4)

Pull request description:

  This is a first PR towards resolving #826 that adds unconfirmed change as coin selection candidates when creating a spend.

  As per https://github.com/wizardsardine/liana/issues/826#issuecomment-1853058734, I haven't made any changes to the `rbfpsbt` command.

  We will also need to apply the same change in the GUI when selecting candidates for coin selection there (see https://github.com/wizardsardine/liana/pull/863#discussion_r1422823362).

ACKs for top commit:
  darosior:
    ACK c0d4320

Tree-SHA512: 8c17f5f8c32913f1ffae3a93ca3e8ee52ac40ee86790e41d73def5ed0c057e110e101797f778715fcd5f6bded1cd170618209323b5114a4f69c02d0ce066a2f2
2024-03-09 18:48:54 +01:00
Antoine Poinsot
bdf8b8f625
Rename IS_BITCOIND_25 to IS_NOT_BITCOIND_26
for f in ; do sed -i 's/IS_BITCOIND_25/IS_NOT_BITCOIND_24/g' tests/test_misc.py; done
2024-02-27 14:18:04 +01:00
pythcoiner
da1ebce5b6 add txids param to listspendtxs 2024-02-24 21:56:48 +01:00
pythcoiner
f2c418f79a get genesis timestamp from bitcoind 2024-02-11 01:59:49 +01:00
jp1ac4
c0d432057d
spend: add warning about fee for ancestor 2024-01-26 07:43:19 +00:00
jp1ac4
62bb4aded4
commands: include unconfirmed change as candidates 2024-01-25 14:57:56 +00:00
jp1ac4
04503225bc
func test: use utils function 2024-01-25 14:55:00 +00:00
Antoine Poinsot
79141e2042
Merge #927: commands: include missing amount in spend response
13398982534d56a5723dfa86723c5917483c8653 commands: include missing amount in response (jp1ac4)

Pull request description:

  This PR follows a discussion around https://github.com/wizardsardine/liana/pull/873#issuecomment-1886715468.

  The GUI uses the `InsufficientFunds` error to get the missing amount when the user is creating a new spend, but it is not straightforward to extract this information in a general way from the RPC error (see https://github.com/wizardsardine/liana/issues/822#issuecomment-1836482355) and instead the spend module's `create_spend` is currently used (see https://github.com/wizardsardine/liana/pull/863).

  With this PR, the missing amount will be included in the `createspend` response rather than as an error.

  These changes are based on suggestions from @darosior and @edouardparis.

  In a follow-up PR, the GUI should revert to using the `createspend` command to calculate the amount left to select.

ACKs for top commit:
  darosior:
    re-ACK 1339898

Tree-SHA512: bf702d6b355339e96e719c1d95824e7941ac4fbaece4ec4cccd00b56ea4683ce7fb0cefc43faa5731b57e7935ef99da3a2c73b84aaeb9fa5f67703c799be2196
2024-01-23 17:33:48 +01:00
jp1ac4
1339898253
commands: include missing amount in response
The GUI uses the InsufficientFunds error to get the missing
amount when the user is creating a new spend.

It is not straightforward to extract this information in a
general way from the RPC error. Instead, this missing amount
will be included in the command response.

These changes are based on suggestions from darosior
and edouardparis.
2024-01-23 15:01:34 +00:00
pythcoiner
79177945ad add timestamp field to getinfo 2024-01-19 13:06:32 +01:00
jp1ac4
5a15c744e7
commands: return warnings from spend creation 2024-01-11 20:06:00 +00:00
Antoine Poinsot
6d2833fc18
Drop watchonly wallet migration for old Windows datadir
It was introduced in v2 (released in August 2023) for migrating datadir created using Liana v1 (May 2023).
2023-12-20 11:21:51 +01:00
Antoine Poinsot
87d1c55d2e
Merge #870: Prepare v4 release
6625e67eed37ba385223dab6256478c312a190dc CHANGELOG: release notes for v4 (Antoine Poinsot)
35e50b4f383652b3cc7929a93e2dd5737fa74118 Bump lianad version to 4.0 (Antoine Poinsot)

Pull request description:

ACKs for top commit:
  darosior:
    self-ACK 6625e67eed37ba385223dab6256478c312a190dc

Tree-SHA512: 2fd3492578ab1bd92c9249b1a4f5bb6134fac6b86febc1bffb33edc184bcbd30aad8554d5e3cb3bb5640ffe8b51c78d7839e1913c126edc5d6de0043c0d54a51
2023-12-12 18:32:52 +01:00
jp1ac4
5f534eb988
spend: a temporary partial fix for LowestFee
This is a temporary partial fix for
https://github.com/bitcoindevkit/coin-select/issues/6 that should be
reverted once the upstream fix has been made.

When calculating the score, the excess should be added to changeless solutions
instead of those with change.

Given a solution has been found, this fix adds or removes the excess to its
incorrectly calculated score as required so that two changeless solutions can
be differentiated if one has higher excess (and therefore pays a higher fee).

Note that the `bound` function is also affected by this bug, which could mean
some branches are not considered when running BnB, but at least this fix will
mean the score for those solutions that are found is correct.
2023-12-12 14:31:36 +00:00
Antoine Poinsot
35e50b4f38
Bump lianad version to 4.0 2023-12-12 15:10:50 +01:00
edouardparis
572567a7e4 Expose ListCoinsEntry derivation_index and is_change 2023-12-11 13:35:30 +01:00
jp1ac4
5391bfe04c
commands: add rbfpsbt command 2023-12-06 17:35:05 +00:00
jp1ac4
68b2503b12
func tests: move function to utils 2023-11-28 13:55:26 +00:00
jp1ac4
fdab722eff
func tests: run black 2023-11-28 13:55:25 +00:00
Antoine Poinsot
6bd6218d64
qa: demonstrate sweep functionality using createpsbt's change_address 2023-11-24 13:51:43 +01:00
jp1ac4
b8fd97fc83
commands: require change for self-send
This adds a new `LowestFeeChangeCondition` metric for use in
coin selection. It's the same as `LowestFee` with the option
to only find solutions with change.

This option is then used for self-sends to ensure only a solution
with change will be returned.
2023-11-24 10:10:22 +00:00
Antoine Poinsot
6b5fc2d1fa
qa: fix flaky test of unconfirmed spend RBF 2023-11-20 14:53:03 +01:00
Antoine Poinsot
cf7c4fbac9
bitcoin: drop spend txid for coins whose spending tx gets RBF'd
Even if the RBF does not spend this coin anymore.
2023-11-17 13:53:00 +01:00
Antoine Poinsot
544167dee4
bitcoin: mark coins whose spending tx got double spent as unspent again 2023-11-17 13:52:59 +01:00