Commit graph

4986 commits

Author SHA1 Message Date
S3RK
c9d0d0cbe4 test: fix bug in 22686
Github-Pull: bitcoin/bitcoin#22742
Rebased-From: 8dcbbbea64
2022-08-01 15:35:06 -07:00
Andrew Chow
58deead9b9 test: Test for ApproximateBestSubset edge case with too little fees
ApproximateBestSubset had an edge case (due to not using
GetSelectionAmount) where it was possible for it to return success but
fail to select enough to cover transaction fees. A test is added that
could trigger this failure prior to the fix being implemented.

Github-Pull: bitcoin/bitcoin#22686
Rebased-From: 92885c4f69
2022-08-01 15:35:06 -07:00
Glenn Willen
87028135ad
Merge pull request #1107 from gwillen/test-fix-1058
Bring Elements up to date with Bitcoin Core 22.0 (Updated)
2022-06-28 16:27:30 -07:00
Glenn Willen
7754db44e4 Merge 03b8b0cb91 into merged_master (Elements PR ElementsProject/elements#1111) 2022-06-27 13:11:53 -07:00
Steven Roose
3e77addbd2
Improve the JSON representation of dynafed parameters 2022-06-07 10:00:35 +01:00
Glenn Willen
06070070a3 ci: Temporarily suppress leak-detection of wallet objects loaded at startup 2022-05-25 11:48:35 -07:00
James Dorfman
efdb2f4df3 getblockchaininfo: remove incorrect fields 'signblock_asm' and 'signblock_hex' from rpc response 2022-04-28 10:14:03 -04:00
Glenn Willen
5889a844db Merge 2dda79cf61 into merged_master (Elements PR ElementsProject/elements#1094) 2022-04-21 15:54:34 -07:00
Glenn Willen
f035196ceb Merge 586e5c7dd7 into merged_master (Elements PR ElementsProject/elements#1062) 2022-04-20 21:51:53 -07:00
Glenn Willen
bf7f050aeb Raise max P2P message size to account for larger elements dynafed header size 2022-03-01 14:21:52 -08:00
Pablo Greco
85c3c2b819 Deprecate con_dyna_deploy_start in favor of evbparams 2021-11-23 14:36:03 +00:00
Pablo Greco
24cafa50cf Implement vbparams for Elements (evbparams) 2021-11-23 14:36:03 +00:00
Andrew Poelstra
242586cea6 lint: fix pylint issues 2021-10-15 00:20:23 +00:00
Andrew Poelstra
ba8273ac94 lint: fix non-pylint linter errors
Includes fixing all the spelling mistakes that are our fault,
but not those present upstream in Core.
2021-10-15 00:20:20 +00:00
Andrew Poelstra
b64ca7f411 Merge 6eed792d43 into merged_master (Elements PR ElementsProject/elements#1050)
Conflicts were mostly obvious, except for those in CreateTransactionInternal.
(This function was moved from wallet.cpp to spend.cpp, and substantially
rewritten, between 0.21 and 22.0.) For those I manually applied the changes
from the diff, which wound up taking a slightly different form.

Also had to update the new test because the `addresses` field of the RPC
output was removed.
2021-10-04 15:13:47 +00:00
Andrew Poelstra
6eed792d43
Merge ElementsProject/elements#1050: wallet: fix a pile of bugs in transaction funding logic
a67a2df330 pset: remove one more intermediate-zero check from the blinding logic (Andrew Poelstra)
9eb285c19d test: add test for confidential non-wallet-owned change (Andrew Poelstra)
185d473fe8 walletcreatefundedpsbt: add functional test for blinding edge cases (Andrew Poelstra)
533da12c2c wallet: make sure extra OP_RETURN output is blinded when called from fundraw (Andrew Poelstra)
b09b63bd1b pset: allow input blinding factors to sum to zero, or value to be 0 (Andrew Poelstra)
9afcb83baf wallet: correctly handle blinding of manually-set change addresses (Andrew Poelstra)
9813c3e74a wallet: fix "cannot unblind IsMine output" check in SignPSBT (Andrew Poelstra)
7103471fd5 walletcreatefundedpsbt: signal blinding data correctly to `FundTransaction` (Andrew Poelstra)

Pull request description:

  Fixes #1049

  Needs backport to 0.21 (and a new rc).

  Although there are several bugs here, none affect the functionaries. There is a more thorough summary in the second-to-last commit message.

ACKs for top commit:
  achow101:
    ACK a67a2df330

Tree-SHA512: 25066c29f080e43cd00c5b33c60a986a8cb5bbf4ca01ceb3b4182c5b8f61979a1d6d946b8f28fa871ec90f44bdb6fc22014b5c11280cf081181db102cd588cdf
2021-10-02 15:13:45 +00:00
Andrew Poelstra
7b69a940eb Merge 846ab81794 into merged_master (Elements PR ElementsProject/elements#1051) 2021-10-02 13:27:49 +00:00
Andrew Poelstra
fec0b59112 pset: make sure combinepsbt doesn't crash when explicit values are missing
I accidentally dropped this check (and its test) in the previous
commits. Restore both.
2021-10-01 20:10:27 +00:00
Andrew Poelstra
187c8094bb combinepsbt: only use explicit values if the corresponding proofs pass 2021-10-01 17:17:41 +00:00
Andrew Poelstra
9eb285c19d test: add test for confidential non-wallet-owned change 2021-09-30 22:58:14 +00:00
Andrew Poelstra
185d473fe8 walletcreatefundedpsbt: add functional test for blinding edge cases
This test actually hits almost all of the edge cases covered by the
previous commits.

  1. The "`walletcreatefundedpsbt` does not propagate blinding factors"
     issue is actually covered by several existing tests, which did not
     fail, but which revealed other bugs as soon as I fixed the issue.

  2. Similarly, the "properly blind (or don't blind) explicit change
     addresses" issue was covered by existing tests, but was revealed
     upon fixing the issue with verifying unblindability in SignPSBT,
     since it resulted in using the wrong blinding key to produce
     rangeproofs for change.

  2a. (While addressing this, I was able to test the SignPSBT checks
      extensively, because the code was producing bad rangeproofs. But
      in the final result this is *not* covered, since it is hard, or
      hopefully impossible, to cajole the wallet into producing outputs
      that can't be unblinded now.)

  3. Once that was fixed, the existing tests create an output whose
     total blinding factor (`v_b + v*a_b`) is zero, which it does by
     having no blinded inputs, explicit change/fee, and a single
     blinded output. This output is spent in the new test. This tests
     one of the "blinding may fail due to zero intermediate values"
     cases.

  4. The new test then intentionally tests that `walletcreatefundedpsbt`
     creates OP_RETURN outputs only when it is legitimately given a
     "blinded inputs, no blinded outputs" transaction, which tests the
     original bug (that blinding factors were propagated correctly from
     `walletfundpsbt`).

  5. In doing so, it hit the "OP_RETURN outputs are not blinded when
     called from fundrawtransaction" bug.

  6. And once this was fixed, `BlindPSBT` has to blind a zero-valued
     output, which triggers the other "blinding may fail due to zero
     intermediate values" case.

For purposes of assigning blame, I'd say that half of this omnibug came
from the new PSET logic and half was latent in Elements for years. The
most concerning thing, I'd say, is the "explicit change addresses cause
outputs to be blinded to the wrong key" bug, which I believe has been
around for the entire history of Elements.
2021-09-30 22:46:33 +00:00
Andrew Poelstra
daa471ddd2 Merge 4c7dc0620a into merged_master (Elements PR ElementsProject/elements#1046) 2021-09-22 02:26:13 +00:00
Andrew Poelstra
d1a1d19113 test: add decodepsbt and analyzepsbt tests for blinding proofs 2021-09-21 21:59:16 +00:00
Andrew Poelstra
6c368ab1a3 Merge a1726c555b into merged_master (Elements PR ElementsProject/elements#1045) 2021-09-21 20:32:03 +00:00
Andrew Poelstra
71c9e90fa0 test: add another functional test for rangeproofs in issuances 2021-09-20 22:10:50 +00:00
Andrew Poelstra
d4a0b6285a test: check asset issuances with SIGHASH_RANGEPROOF
Asset issuance rangeproofs are not actually covered by SIGHASH_RANGEPROOF
so this test serves more as a sanity check that our various signing
mechanisms still work with issuances. Sure enough, it uncovered a PSET
bug (fixed) and a blindrawtransaction bug (left a FIXME).
2021-09-19 20:58:07 +00:00
Andrew Poelstra
0907fa0f6f test: support asset issuance in test framework sighashes
Replaces #932
2021-09-19 20:58:07 +00:00
Andrew Poelstra
34eafaf761 test: sign using the PSET interface and SIGHASH_RANGEPROOF 2021-09-19 14:52:47 +00:00
Andrew Poelstra
7d39e430c7 test: check that signrawtransaction does not erase RANGEPROOF signatures 2021-09-19 14:18:13 +00:00
Andrew Poelstra
ac54a2f765 test: check that signing with the RANGEPROOF flag works 2021-09-19 14:10:21 +00:00
Andrew Poelstra
5d8b55ce47 Merge f7f9555792 into merged_master (Elements PR ElementsProject/elements#1044) 2021-09-18 23:15:14 +00:00
Andrew Poelstra
92d6f321b8 Merge 388d47f9a3 into merged_master (Elements PR ElementsProject/elements#1010)
Basically just reconstructed the diff since so much code had been moved.
2021-09-18 15:46:10 +00:00
Andrew Poelstra
dc31deacff Merge bc0494cc39 into merged_master (Elements PR ElementsProject/elements#1040) 2021-09-18 14:58:14 +00:00
Andrew Poelstra
7da9e74a39 Merge b456b72353 into merged_master (Elements PR ElementsProject/elements#1039) 2021-09-18 14:20:58 +00:00
Andrew Poelstra
f7f9555792
Merge ElementsProject/elements#1044: Define Taproot activation parameters for Liquid
3cb9612faa test: add test for Taproot activation (Andrew Poelstra)
5291c0d9d9 chainparams: add undocumented regtest/testnet only -con_taproot_signal_start option (Andrew Poelstra)
cc6b933478 add missing taproot activation params for Liquid v1 (Andrew Poelstra)
bec6bcf31b versionbits: allow specific deployments to override the signalling/threshold values (Andrew Poelstra)

Pull request description:

  Sets Taproot to start signalling around noon (California time) on Nov 1, 2021, assuming 95% of blocks are produced between now and then.

  Will activate after one week of 100% signalling. If we can pull this off on the first or second try, we will beat Bitcoin which currently looks like it will activate on Nov 16.

  **Edit:** actually, even without Speedy Trial, there is one full period (week) where Taproot will be "locked in" but not "active". So it will activate on Nov 15 at the earliest.

ACKs for top commit:
  achow101:
    ACK 3cb9612faa

Tree-SHA512: c3a80d39ba86a0d762a3057cb9c45e379c70c2daee8ff2e54978a4c32118c935c8909d872ac9f873e283441c52c1974c06268f10dc7bf9e9e000c21063ac84d7
2021-09-18 03:22:30 +00:00
Andrew Poelstra
e4c9cc06dc Merge 250c8e59d5 into merged_master (Elements PR ElementsProject/elements#1030) 2021-09-18 03:17:06 +00:00
Andrew Poelstra
edac5081f4 Merge 1240172eaa into merged_master (Elements PR ElementsProject/elements#1038)
Surprisingly the only conflicts were converting nullopts
2021-09-18 02:10:36 +00:00
Andrew Poelstra
3cb9612faa test: add test for Taproot activation 2021-09-18 00:50:17 +00:00
Andrew Poelstra
7ba9f416d7 Merge e88f0b7045 into merged_master (Elements PR ElementsProject/elements#1034) 2021-09-18 00:04:33 +00:00
Andrew Poelstra
446f764bae Merge e5ac786d7e into merged_master (Elements PR ElementsProject/elements#1033)
This fixes a bug that was eliminated by #22008 -- although a conceptually
similar one was reintroduced (basically, we do a "test blinding" for fee
estimation, then potentially delete a change output, then we actually blind
the tranasction .... but if removing the change output pushes us into an
edge-case scenario for blinding, Bad Things happen).

Patched in a simple hack. We should fix this properly in a post-22 PR.

Unrelatedly, corrected a comment in the functional test.
2021-09-17 23:22:56 +00:00
Andrew Poelstra
388d47f9a3
Merge ElementsProject/elements#1010: Support supplying contract hash to issueasset RPC
47d43f14ad Support supplying contract hash to issueasset RPC (Steven Roose)

Pull request description:

  forward port of https://github.com/ElementsProject/elements/pull/993.
  Closes https://github.com/ElementsProject/elements/issues/985.

ACKs for top commit:
  apoelstra:
    ACK 47d43f14ad

Tree-SHA512: e29cda86291c8fe4650595129af477c6dc8648465a5305002ae521bac21a114d6a1c44738786351ac4355eafdcb0da3e4e42c8f204137f9e31e03df20a91db64
2021-09-16 23:06:23 +00:00
Andrew Poelstra
bc0494cc39
Merge ElementsProject/elements#1040: regtest: change network magic away from liquid v1
e57b4c51ad regtest: change network magic away from liquid v1 (Andrew Poelstra)

Pull request description:

  We don't want connectivity issues between Liquid and custom test networks.

ACKs for top commit:
  stevenroose:
    ACK e57b4c51ad

Tree-SHA512: 3ddd626496d7877551c41b089932784bcb752962089fd3e6baa5e9ea6acac44b1b4c5c915b061892b712849d12455fae00347885cecb0e0a3b59a134d91d4014
2021-09-15 22:36:31 +00:00
Andrew Poelstra
b456b72353
Merge ElementsProject/elements#1039: claimpegin: sanity-check fee in case fallbackfee is disabled, throw explicit exception
fc8bfc1f2c claimpegin: add regression test for behavior when fallbackfee is disabled (Andrew Poelstra)
fd520079a1 claimpegin: sanity-check fee in case fallbackfee is disabled, throw explicit exception (Andrew Poelstra)

Pull request description:

  Produce a much less confusing error message in `claimpegin` in the case that estimatesmartfee fails and no fallbackfee is set.

ACKs for top commit:
  stevenroose:
    ACK fc8bfc1f2c

Tree-SHA512: 2ae658ab3dc90b7319d047c192401a0dcc97e015e45b5b0db71db1d89d63605ba107312d8b4cf1c4aaef72437aa20aa33b442744f64fc08535b15610e6f4a526
2021-09-15 22:36:08 +00:00
Steven Roose
47d43f14ad
Support supplying contract hash to issueasset RPC 2021-09-15 16:23:32 -01:00
Andrew Poelstra
250c8e59d5
Merge ElementsProject/elements#1030: [forward port] When validation is waiting for parent chain daemon, "stall"
b2e1cc38de Regression test for pegin validation issues during sync (Glenn Willen)
d5042b41c8 Finish removing 'recheckpeginblockinterval'; move MainchainRPCCheck (Glenn Willen)
313f73d5b2 When validation is waiting for parent chain daemon, "stall". (Andrew Poelstra)

Pull request description:

  Forward-port of #1022

ACKs for top commit:
  gwillen:
    utACK b2e1cc38de, verified that it contains only the requested changes from da11d7b6fd.

Tree-SHA512: 971b6a137efdc54f84995b17595346bf3d3ebd5a04eef1676225c664923e0b52393550bc51ea366c4d3010aa35a9de16da0643bb5bfb40c7eb788a180c99b1a0
2021-09-14 20:48:05 +00:00
Andrew Chow
3ac7e78a84 pset, rpc: Better error messages for imbalance failure conditions
Instead of not failing and silently allowing bad PSETs to be created,
provide error messages that explain why the operation the user did was
wrong. Specifically for combining PSETs such that they would become
fully blinded but have imbalanced values and blinders, and for blinding
a PSET when the wallet has a blind input but no outputs to blind (would
result in an imbalance).
2021-09-13 18:36:38 -04:00
Glenn Willen
b2e1cc38de Regression test for pegin validation issues during sync
Add a regression test for https://github.com/ElementsProject/elements/issues/891 .

This checks that we can sync successfully when making a bunch of new blocks
just as we have transient loss of parent daemon connectivity. This reliably
fails without the fix, and reliably succeeds with it. (It stands in for the
situation, more common in production, where we sync faster than the parent
daemon can keep up after a long outage.)
2021-09-13 22:10:36 +00:00
Andrew Poelstra
313f73d5b2 When validation is waiting for parent chain daemon, "stall".
Currently, if -validatepegin is given, and block validation can't proceed
because the parent chain is not synced, we mark the block invalid and put
it in a queue to be "revalidated" later. Unfortunately, marking a block
invalid has downstream consequences, in particular causing descendant blocks
to be marked invalid, which are not currently fixed by the queue.

Instead, we'll use a different strategy: if the mainchain daemon isn't
sufficiently synced to validate a block, we will "stall" connecting that
block to the chain, and have ActivateBestChain simply keep the tip at the
previous block until we're ready.

We can still download and validate (partly) blocks past this point while
we're waiting. They will be connected once the parent chain daemon catches
up.
2021-09-13 22:10:09 +00:00
Andrew Chow
a7ef9f325d pset, test: Test a PSET coinjoin workflow 2021-09-11 21:02:22 -04:00
Andrew Chow
59f65a3f73 rpc, pset: Include blinded value and asset proofs in decodepsbt 2021-09-11 20:58:40 -04:00