Commit graph

100 commits

Author SHA1 Message Date
Andrew Poelstra
a1f0aea3d7 Merge 43665e3ca0 into merged_master (Elements PR ElementsProject/elements#1055) 2021-10-14 19:32:30 +00:00
Andrew Poelstra
0e1007fa7b minor PSET fix 2021-10-06 19:10:15 +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
daa471ddd2 Merge 4c7dc0620a into merged_master (Elements PR ElementsProject/elements#1046) 2021-09-22 02:26:13 +00:00
Andrew Poelstra
35cfda73b9 PSET: do not assume in GetUnsignedTx that explicit amounts/assets are available 2021-09-21 20:33:31 +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
1b23ad7093 pset: fix encoding of blinded asset issuances 2021-09-19 20:58:07 +00:00
Andrew Poelstra
9c3c61aa0a psbt: make sure rangeproofs are present in the confidential version of the unsigned tx
These rangeproofs are covered by signature in both Taproot and
SIGHASH_RANGEPROOF signatures, so they need to be present.
2021-09-19 14:52:47 +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 Chow
9f94966581 pset: Allow GetUnsignedTx to force unblinded values
In order to get the Unique id for a PSET, the explicit values and assets
need to be used. Since GetUnsignedTx is used to create the tx that is
hashed, modify GetUnsignedTx so that the explicit values and assets are
used when requested.
2021-09-11 20:58:40 -04:00
Andrew Chow
f9f084f785 pset: Add missing fields to merging and fix combinepsbt
* Add some fields that were missing in PSBTInput::Merge and PSBTOutput::Merge
* Remove incorrect check that explicit values and assets aren't present
  when blinded
* Fix bug in combinepsbt where the condition was inverted
2021-09-11 20:58:40 -04:00
Andrew Chow
37c925f472 pset: Do not remove amounts after blinding 2021-09-07 20:44:30 -04:00
Andrew Poelstra
7d1c77f0a1 Merge 1ba24fe9b3 into merged_master (Elements PR ElementsProject/elements#1002)
This forward-ports the new Taproot sighash but does not fix a couple
22-blocked TODOs related to the MissingDataBehavior enum. Should be fixed
in a followup commit.

One nontrivial change I had to make was feeding the genesis hash to SignTransaction
(the "global" one in script/sign.cpp) so that it could correctly compute
the sighash at signing time.
2021-09-04 22:14:42 +00:00
Andrew Poelstra
36e5e2a7f1 Merge 9a154599fe into merged_master (Elements PR ElementsProject/elements#900)
Surprisingly easy to do. Almost all of the diff resolution was mechanically
  * replacing boost::variant with std::variant
  * replacing Optional with std::optional
     * then replacing `nullopt` with `std::nullopt`
  * updating the RPC functions for the new RPCArg::Default type
  * update the tests/ directory to make new (since 22) tests use arrays for
    createrawtransaction outputs
  * other ad-hoc changes to function parameters etc (not too many of these)

I had to "really" change the code in PrecomputePSBTData, which was introduced
in 22.0 and affected by PSET, but this function was like 8 lines long so it
was easy.

Reviewing the diff may be a bit difficult because of the mix of mechanical
changes and ad-hoc things. Probably the most straightforward thing to do
is to redo the merge, `sed -i` to fix the boost::variant and Optional stuff,
then diff the remaining conflicts against this commit.

TODO: grep for `blindpsbt` and you will see that this RPC is still referenced
in documentation and help text even though it was deleted. Need to fix this
in 0.21 in a separate PR.
2021-09-04 19:34:14 +00:00
Andrew Poelstra
0afcb6d978 Merge 5c2e2afe99 into merged_master (Bitcoin PR bitcoin/bitcoin#21365)
This introduces Taproot wallet support. I fixed all the merge conflicts
and ensured that the tests pass, but this is still using the old sighash
(before Russell/Sanket/I redid it) so is not actually production ready.
Will be fixed when we bring Elements #1002 in.
2021-08-03 20:43:53 +00:00
Andrew Chow
64b30bfc3d Enable analyzepsbt 2021-06-22 14:42:38 -04:00
Andrew Chow
b65a00f095 Add PSBTOutput::GetTxOut()
Helper function for getting a CTxOut for a PSBTOutput
2021-06-22 14:42:38 -04:00
Andrew Chow
0e2f1ff441 Make m_peg_in_witness during SignPSBTInput 2021-06-22 14:42:19 -04:00
Andrew Chow
bd97836767 Update FinalizeAndExtract for PSEt 2021-06-22 14:42:19 -04:00
Andrew Chow
2c0cee5a20 Update GetUnsignedTx for PSET 2021-06-22 14:42:19 -04:00
Andrew Chow
e9bfff25db Allow empty scriptPubKeys 2021-06-22 14:42:19 -04:00
Andrew Chow
a8a6f4c999 Add IsBlinded and IsFullyBlinded helpers for PSBT 2021-06-22 14:42:19 -04:00
Andrew Chow
bad1876e03 Re-enable and fix PSBT signing 2021-06-22 14:42:19 -04:00
Andrew Chow
6890461bfe Implement blinded combiner stuff 2021-06-22 13:54:50 -04:00
Andrew Chow
2220d844ef Return peg-in UTXO with GetUTXO
Peg-ins don't have a typical UTXO. Instead we can get a "UTXO" using the
peg-in data.
2021-06-22 13:54:50 -04:00
Andrew Chow
33c694f822 Helper functions to determine whether a PSBTOutput is blinded 2021-06-22 13:54:50 -04:00
Andrew Chow
ee28be3018 Extract elements fields for tx into psbt 2021-06-22 13:54:50 -04:00
Andrew Chow
e860cd0f42 Add a PSBT constructor for providing the version 2021-06-22 13:54:50 -04:00
Andrew Chow
e467ec68ad Update PSBT::UpdatePSBTOutput to use GetUnsignedTx 2021-06-22 13:54:50 -04:00
Andrew Chow
a34474e25a Allow specifying PSBT version in constructor 2021-06-22 13:54:50 -04:00
Andrew Chow
139ac3613e Implement PSBTv2 AddInput and AddOutput 2021-06-22 13:54:50 -04:00
Andrew Chow
f269d1170c Update FinalizeAndExtract for v2 2021-06-22 13:54:50 -04:00
Andrew Chow
23f644206b Update SignPSBTInput for PSBTv2 2021-06-22 13:54:50 -04:00
Andrew Chow
d8dba3333b Add PSBTInput::GetOutPoint
Helper for getting the PSBTInput COutPoint
2021-06-22 13:54:50 -04:00
Andrew Chow
4ff2593280 Implement PSBTv2 field merging 2021-06-22 13:54:50 -04:00
Andrew Chow
cd5515a266 Change PSBT::AddOutput to take just PSBTOutput 2021-06-22 13:54:50 -04:00
Andrew Chow
90cd7ec5d5 Change PSBT::AddInput to take just PSBTInput 2021-06-22 13:54:50 -04:00
Andrew Chow
bd1a57bd80 Add PSBT::GetUniqueID
The unique ID for PSBTv2 is different from v0. Use this function to get
the ID without requiring the caller to know the version number.
2021-06-22 13:54:50 -04:00
Andrew Chow
32bdf2d97e Add PSBT::GetUnsignedTx
A helper function for getting the unsigned transaction regardless of
psbt version.
2021-06-22 13:54:50 -04:00
Andrew Chow
10bf24726b Add PSBT::ComputeLockTime()
Function to compute the lock time for the transaction
2021-06-22 13:54:50 -04:00
Andrew Chow
3c647b7a54 Replace PSBT::GetInputUTXO with PSBTInput::GetUTXO
Now that PSBTInput's track their own prevouts, there's no need for a
PSBT global function to fetch input specific data.
2021-06-22 13:54:50 -04:00
Andrew Chow
32234dfa68 Call CacheUnsignedTxPieces in PSBT constructor 2021-06-22 13:54:50 -04:00
Andrew Chow
c32950e02b Add PSBT::CacheUnsignedTxPieces
Fetches the PSBTv2 fields from PSBTv0's global unsigned tx. This allows
us to pretend everything internally is a PSBTv2 and makes things easier
to work with.
2021-06-22 13:54:50 -04:00
Andrew Chow
2042765520 Have PSBTInput and PSBTOutput know the PSBT's version 2021-06-22 13:54:50 -04:00
Andrew Chow
20e8dff880 Merge global xpubs in joinpsbts and combinepsbts 2021-06-22 13:54:50 -04:00
Andrew Poelstra
9a3b7cda65 Merge 2c0fc856a6 into merged_master (Bitcoin PR #20464) 2021-06-20 19:00:02 +00:00
Andrew Poelstra
acf709b3ab Merge bd6af53e1f into merged_master (Bitcoin PR #20480)
what a trainwreck of a programming language..
2021-06-17 15:15:29 +00:00
Andrew Poelstra
0a58119253 Merge 68c7acf6bb into merged_master (Bitcoin PR #20671) 2021-06-15 16:40:45 +00:00