Commit graph

62 commits

Author SHA1 Message Date
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 Chow
ad2b2d7c58 Add GetVersion helper to PSBT 2021-06-03 15:44:19 -04:00
Andrew Chow
fdf71def4c Remove PSET and disable PSBT/PSET things for now
Reset back to Bitcoin PSBT and disable PSBT/PSET handling in wallet and
rpc.

This is just a reset to allow for PSBTv2 change and then a new and
improved PSET.
2021-06-03 15:44:19 -04:00
Andrew Poelstra
0bc6dbbce1 Merge e6207229b8 into merged_master (Elements PR #911)
Spent a while figuring out where this new function should live now that
the PSBT stuff has been pulled into src/psbt.cpp and the wallet, and isn't
mixed up with the RPC logic.

In the end I modified the the function to return a normal error rather
than throwing an RPC exception and put it in src/psbt.cpp with the other
functions that behave this way.
2020-11-30 14:31:38 +00:00
Andrew Poelstra
2a04500584 Merge a12d9e5fd2 into merged_master (Bitcoin PR #19687) 2020-11-28 13:35:24 +00:00
Andrew Poelstra
d664527f5a Merge a24806c25d into merged_master (Bitcoin PR #19215) 2020-11-26 01:09:18 +00:00
Andrew Poelstra
4839db857d Merge c27330897d into merged_master (Bitcoin PR #18027) 2020-11-26 01:09:11 +00:00
Andrew Poelstra
fd37b7c5d6 Merge 54f812d9d2 into merged_master (Bitcoin PR #18673) 2020-11-26 01:08:23 +00:00
Andrew Poelstra
68d0a25901 Merge 1326092e6c into merged_master (Bitcoin PR #17156)
This fixes a segfault I introduced in 981df590811 (#17371) a couple hundred PRs
ago, where we might out-of-bounds access the vout arrray of a non_witness_utxo
transaction in a PSBT.

This logic should probably be refactored after the rebase -- we sift through
the non_witness_utxos to find a scriptpubkey, which we use to get a wallet
provider, so we can pass this to SignPSBTInput, which then repeats the same
logic (for its own reasons, and without the segfault bug)....and we aren't
even calling SignPSBTInput for signing reasons! It has something to do with
blinding.
2020-11-14 16:52:12 +00:00
Andrew Poelstra
009bc2fdfb Merge 99813a9745 into merged_master (Bitcoin PR #17829) 2020-11-14 16:52:02 +00:00
Andrew Poelstra
9709d02c23 Merge fae94785d9 into merged_master (Bitcoin PR #17524)
lol converting the psbt test vector to a pset one was pretty brutal. Conversion to
hex using rust-bitcoin and then manual hex-editing in vim.
2020-11-14 16:51:56 +00:00
Andrew Poelstra
fd78a12518 Merge 2949ea924f into merged_master (Elements PR #751) 2020-11-14 16:51:52 +00:00
Andrew Poelstra
821f5256a5 Merge 46d6930f8c into merged_master (Bitcoin PR #16659) 2020-11-09 21:20:41 +00:00
Andrew Poelstra
62ce823f8f Merge c67ef2938c into merged_master (Elements PR #600)
Also uncommented a bunch of PSBT functional tests (had to add a fee output
to one transaction, update `find_output` to skip CT outputs, and change two
constant checks at the end of the commented-out section).
2020-11-09 21:20:10 +00:00
Andrew Poelstra
16a3be0fc8 Merge 2f717fb5cd into merged_master (Bitcoin PR #15427) 2020-11-09 03:58:18 +00:00
Andrew Poelstra
68d9951825 Merge d0f81a96d9 into merged_master (Bitcoin PR #16129) 2020-11-06 15:20:13 +00:00
Andrew Poelstra
a8581ea138 Merge 6a135fbe5b into merged_master (Bitcoin PR #15638) 2020-10-28 03:16:57 +00:00
Andrew Poelstra
d0fde0a054 Merge e439aeb30c into merged_master (Bitcoin PR #15508) 2020-10-28 00:54:38 +00:00
Andrew Chow
4600479058 psbt: always put a non_witness_utxo and don't remove it
Offline signers will always need a non_witness_utxo so make sure it is
there.
2020-06-24 16:32:19 -04:00
Andrew Chow
5279d8bc07 psbt: Allow both non_witness_utxo and witness_utxo 2020-06-24 16:31:42 -04:00
Glenn Willen
a6cb0b0c29 [gui] PSBT Operations Dialog (sign & broadcast)
Add a "PSBT Operations" dialog, reached from the "Load PSBT..." menu
item, giving options to sign or broadcast the loaded PSBT as
appropriate, as well as copying the result to the clipboard or saving
it to a file.
2020-06-19 02:20:04 -07:00
MarcoFalke
fa488f131f
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
2020-04-16 13:33:09 -04:00
fanquake
1326092e6c
Merge #17156: psbt: check that various indexes and amounts are within bounds
deaa6dd144 psbt: check output index is within bounds before accessing (Andrew Chow)
f1ef7f0aa4 Don't calculate tx fees for PSBTs with invalid money values (Andrew Chow)

Pull request description:

  Fixes #17149

  Two classes of issues were found by the psbt fuzzer: values out of range and causing overflows, and prevout indexes being out of range. This PR fixes both.

  When accessing a specific output using the index given in the tx, check that it is actually a possible output before trying to access the output.

  When summing and checking amounts for `decodepsbt` and `analyzepsbt`, make sure that the values are actually valid money values.. Otherwise, stop summing and don't show the fee. For `analyzepsbt`, return that the next role is the Creator since the Creator needs to remake the transaction to be valid.

ACKs for top commit:
  practicalswift:
    ACK deaa6dd144 -- only change since last ACK was the addition of tests
  gwillen:
    tested ACK deaa6dd, would also like to see this merged!

Tree-SHA512: 06c36720bbb5a7ab1c29f7d15878bf9f0d3e5760c06bff479d412e1bf07bb3e0e9ab6cca820a4bfedaab71bfd7af813807e87cbcdf0af25cc3f66a53a06dbcfd
2020-01-29 19:39:50 +08:00
Andrew Chow
deaa6dd144 psbt: check output index is within bounds before accessing 2020-01-06 12:57:21 -05:00
MarcoFalke
aaaaad6ac9
scripted-diff: Bump copyright of files changed in 2019
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
2019-12-30 10:42:20 +13:00
Andrew Chow
638e40cb60 Have a PSBTAnalysis state that indicates invalid PSBT
Invalid PSBTs need to be re-created, so the next role is the
Creator (new PSBTRole). Additionally, we need to know what went
wrong so an error field was added to PSBTAnalysis.

A PSBTAnalysis indicating invalid will have empty everything,
next will be set to PSBTRole::CREATOR, and an error message.
2019-11-19 14:54:08 -05:00
Andrew Chow
73711eb0bb Merge psbt peg-in data 2019-10-21 18:02:14 -04:00
Andrew Chow
4ad849fed2 Finalize psbt peg-ins 2019-10-21 18:02:14 -04:00
practicalswift
084e17cebd Remove unused includes 2019-10-15 22:56:43 +00:00
Glenn Willen
2848b520b2 PSBT for Confidential Assets 2019-07-31 10:50:03 -07:00
Wladimir J. van der Laan
2f717fb5cd
Merge #15427: Add support for descriptors to utxoupdatepsbt
26fe9b9909 Add support for descriptors to utxoupdatepsbt (Pieter Wuille)
3135c1a2d2 Abstract out UpdatePSBTOutput from FillPSBT (Pieter Wuille)
fb90ec3c33 Abstract out EvalDescriptorStringOrObject from scantxoutset (Pieter Wuille)
eaf4f88734 Abstract out IsSegWitOutput from utxoupdatepsbt (Pieter Wuille)

Pull request description:

  This adds a descriptors argument to the `utxoupdatepsbt` RPC. This means:
  * Input and output scripts and keys will be filled in when known.
  * P2SH-witness inputs will be filled in from the UTXO set when a descriptor is provided that shows they're spending segwit outputs.

  This also moves some (newly) shared code to separate functions: `UpdatePSBTOutput` (an analogue to `SignPSBTInput`), `IsSegWitOutput`, and `EvalDescriptorStringOrObject` (implementing the string or object notation parsing used in `scantxoutset`).

ACKs for top commit:
  jnewbery:
    utACK 26fe9b9909
  laanwj:
    utACK 26fe9b9909 (will hold merging until response to promag's comments)
  promag:
    ACK 26fe9b9, checked refactors and tests look comprehensive. Still missing a release note but can be added later.

Tree-SHA512: 1d833b7351b59d6c5ded6da399ff371a8a2a6ad04c0a8f90e6e46105dc737fa6f2740b1e5340280d59e01f42896c40b720c042f44417e38dfbee6477b894b245
2019-07-02 16:53:22 +02:00
practicalswift
eca9767673 Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
Steven Roose
52f6f6905b
WIP: Fix compilation after merge 2019-05-20 16:22:05 +01:00
Pieter Wuille
3135c1a2d2 Abstract out UpdatePSBTOutput from FillPSBT 2019-05-10 14:31:22 -07:00