Bitcoin Core  0.19.99
P2P Digital Currency
psbt.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_PSBT_H
6 #define BITCOIN_PSBT_H
7 
8 #include <attributes.h>
9 #include <node/transaction.h>
10 #include <optional.h>
11 #include <policy/feerate.h>
12 #include <primitives/transaction.h>
13 #include <pubkey.h>
14 #include <script/sign.h>
15 #include <script/signingprovider.h>
16 
17 // Magic bytes
18 static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff};
19 
20 // Global types
21 static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00;
22 
23 // Input types
24 static constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00;
25 static constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01;
26 static constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02;
27 static constexpr uint8_t PSBT_IN_SIGHASH = 0x03;
28 static constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04;
29 static constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05;
30 static constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06;
31 static constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07;
32 static constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08;
33 
34 // Output types
35 static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00;
36 static constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01;
37 static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02;
38 
39 // The separator is 0x00. Reading this in means that the unserializer can interpret it
40 // as a 0 length key which indicates that this is the separator. The separator has no value.
41 static constexpr uint8_t PSBT_SEPARATOR = 0x00;
42 
44 struct PSBTInput
45 {
52  std::map<CPubKey, KeyOriginInfo> hd_keypaths;
53  std::map<CKeyID, SigPair> partial_sigs;
54  std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown;
55  int sighash_type = 0;
56 
57  bool IsNull() const;
58  void FillSignatureData(SignatureData& sigdata) const;
59  void FromSignatureData(const SignatureData& sigdata);
60  void Merge(const PSBTInput& input);
61  bool IsSane() const;
62  PSBTInput() {}
63 
64  template <typename Stream>
65  inline void Serialize(Stream& s) const {
66  // Write the utxo
67  // If there is a non-witness utxo, then don't add the witness one.
68  if (non_witness_utxo) {
70  OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
71  SerializeToVector(os, non_witness_utxo);
72  } else if (!witness_utxo.IsNull()) {
74  SerializeToVector(s, witness_utxo);
75  }
76 
77  if (final_script_sig.empty() && final_script_witness.IsNull()) {
78  // Write any partial signatures
79  for (auto sig_pair : partial_sigs) {
80  SerializeToVector(s, PSBT_IN_PARTIAL_SIG, MakeSpan(sig_pair.second.first));
81  s << sig_pair.second.second;
82  }
83 
84  // Write the sighash type
85  if (sighash_type > 0) {
87  SerializeToVector(s, sighash_type);
88  }
89 
90  // Write the redeem script
91  if (!redeem_script.empty()) {
93  s << redeem_script;
94  }
95 
96  // Write the witness script
97  if (!witness_script.empty()) {
99  s << witness_script;
100  }
101 
102  // Write any hd keypaths
104  }
105 
106  // Write script sig
107  if (!final_script_sig.empty()) {
109  s << final_script_sig;
110  }
111  // write script witness
112  if (!final_script_witness.IsNull()) {
114  SerializeToVector(s, final_script_witness.stack);
115  }
116 
117  // Write unknown things
118  for (auto& entry : unknown) {
119  s << entry.first;
120  s << entry.second;
121  }
122 
123  s << PSBT_SEPARATOR;
124  }
125 
126 
127  template <typename Stream>
128  inline void Unserialize(Stream& s) {
129  // Used for duplicate key detection
130  std::set<std::vector<unsigned char>> key_lookup;
131 
132  // Read loop
133  bool found_sep = false;
134  while(!s.empty()) {
135  // Read
136  std::vector<unsigned char> key;
137  s >> key;
138 
139  // the key is empty if that was actually a separator byte
140  // This is a special case for key lengths 0 as those are not allowed (except for separator)
141  if (key.empty()) {
142  found_sep = true;
143  break;
144  }
145 
146  // First byte of key is the type
147  unsigned char type = key[0];
148 
149  // Do stuff based on type
150  switch(type) {
152  {
153  if (!key_lookup.emplace(key).second) {
154  throw std::ios_base::failure("Duplicate Key, input non-witness utxo already provided");
155  } else if (key.size() != 1) {
156  throw std::ios_base::failure("Non-witness utxo key is more than one byte type");
157  }
158  // Set the stream to unserialize with witness since this is always a valid network transaction
159  OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() & ~SERIALIZE_TRANSACTION_NO_WITNESS);
160  UnserializeFromVector(os, non_witness_utxo);
161  break;
162  }
164  if (!key_lookup.emplace(key).second) {
165  throw std::ios_base::failure("Duplicate Key, input witness utxo already provided");
166  } else if (key.size() != 1) {
167  throw std::ios_base::failure("Witness utxo key is more than one byte type");
168  }
169  UnserializeFromVector(s, witness_utxo);
170  break;
171  case PSBT_IN_PARTIAL_SIG:
172  {
173  // Make sure that the key is the size of pubkey + 1
174  if (key.size() != CPubKey::SIZE + 1 && key.size() != CPubKey::COMPRESSED_SIZE + 1) {
175  throw std::ios_base::failure("Size of key was not the expected size for the type partial signature pubkey");
176  }
177  // Read in the pubkey from key
178  CPubKey pubkey(key.begin() + 1, key.end());
179  if (!pubkey.IsFullyValid()) {
180  throw std::ios_base::failure("Invalid pubkey");
181  }
182  if (partial_sigs.count(pubkey.GetID()) > 0) {
183  throw std::ios_base::failure("Duplicate Key, input partial signature for pubkey already provided");
184  }
185 
186  // Read in the signature from value
187  std::vector<unsigned char> sig;
188  s >> sig;
189 
190  // Add to list
191  partial_sigs.emplace(pubkey.GetID(), SigPair(pubkey, std::move(sig)));
192  break;
193  }
194  case PSBT_IN_SIGHASH:
195  if (!key_lookup.emplace(key).second) {
196  throw std::ios_base::failure("Duplicate Key, input sighash type already provided");
197  } else if (key.size() != 1) {
198  throw std::ios_base::failure("Sighash type key is more than one byte type");
199  }
200  UnserializeFromVector(s, sighash_type);
201  break;
203  {
204  if (!key_lookup.emplace(key).second) {
205  throw std::ios_base::failure("Duplicate Key, input redeemScript already provided");
206  } else if (key.size() != 1) {
207  throw std::ios_base::failure("Input redeemScript key is more than one byte type");
208  }
209  s >> redeem_script;
210  break;
211  }
213  {
214  if (!key_lookup.emplace(key).second) {
215  throw std::ios_base::failure("Duplicate Key, input witnessScript already provided");
216  } else if (key.size() != 1) {
217  throw std::ios_base::failure("Input witnessScript key is more than one byte type");
218  }
219  s >> witness_script;
220  break;
221  }
223  {
224  DeserializeHDKeypaths(s, key, hd_keypaths);
225  break;
226  }
227  case PSBT_IN_SCRIPTSIG:
228  {
229  if (!key_lookup.emplace(key).second) {
230  throw std::ios_base::failure("Duplicate Key, input final scriptSig already provided");
231  } else if (key.size() != 1) {
232  throw std::ios_base::failure("Final scriptSig key is more than one byte type");
233  }
234  s >> final_script_sig;
235  break;
236  }
238  {
239  if (!key_lookup.emplace(key).second) {
240  throw std::ios_base::failure("Duplicate Key, input final scriptWitness already provided");
241  } else if (key.size() != 1) {
242  throw std::ios_base::failure("Final scriptWitness key is more than one byte type");
243  }
244  UnserializeFromVector(s, final_script_witness.stack);
245  break;
246  }
247  // Unknown stuff
248  default:
249  if (unknown.count(key) > 0) {
250  throw std::ios_base::failure("Duplicate Key, key for unknown value already provided");
251  }
252  // Read in the value
253  std::vector<unsigned char> val_bytes;
254  s >> val_bytes;
255  unknown.emplace(std::move(key), std::move(val_bytes));
256  break;
257  }
258  }
259 
260  if (!found_sep) {
261  throw std::ios_base::failure("Separator is missing at the end of an input map");
262  }
263  }
264 
265  template <typename Stream>
267  Unserialize(s);
268  }
269 };
270 
273 {
276  std::map<CPubKey, KeyOriginInfo> hd_keypaths;
277  std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown;
278 
279  bool IsNull() const;
280  void FillSignatureData(SignatureData& sigdata) const;
281  void FromSignatureData(const SignatureData& sigdata);
282  void Merge(const PSBTOutput& output);
283  bool IsSane() const;
285 
286  template <typename Stream>
287  inline void Serialize(Stream& s) const {
288  // Write the redeem script
289  if (!redeem_script.empty()) {
291  s << redeem_script;
292  }
293 
294  // Write the witness script
295  if (!witness_script.empty()) {
297  s << witness_script;
298  }
299 
300  // Write any hd keypaths
302 
303  // Write unknown things
304  for (auto& entry : unknown) {
305  s << entry.first;
306  s << entry.second;
307  }
308 
309  s << PSBT_SEPARATOR;
310  }
311 
312 
313  template <typename Stream>
314  inline void Unserialize(Stream& s) {
315  // Used for duplicate key detection
316  std::set<std::vector<unsigned char>> key_lookup;
317 
318  // Read loop
319  bool found_sep = false;
320  while(!s.empty()) {
321  // Read
322  std::vector<unsigned char> key;
323  s >> key;
324 
325  // the key is empty if that was actually a separator byte
326  // This is a special case for key lengths 0 as those are not allowed (except for separator)
327  if (key.empty()) {
328  found_sep = true;
329  break;
330  }
331 
332  // First byte of key is the type
333  unsigned char type = key[0];
334 
335  // Do stuff based on type
336  switch(type) {
338  {
339  if (!key_lookup.emplace(key).second) {
340  throw std::ios_base::failure("Duplicate Key, output redeemScript already provided");
341  } else if (key.size() != 1) {
342  throw std::ios_base::failure("Output redeemScript key is more than one byte type");
343  }
344  s >> redeem_script;
345  break;
346  }
348  {
349  if (!key_lookup.emplace(key).second) {
350  throw std::ios_base::failure("Duplicate Key, output witnessScript already provided");
351  } else if (key.size() != 1) {
352  throw std::ios_base::failure("Output witnessScript key is more than one byte type");
353  }
354  s >> witness_script;
355  break;
356  }
358  {
359  DeserializeHDKeypaths(s, key, hd_keypaths);
360  break;
361  }
362  // Unknown stuff
363  default: {
364  if (unknown.count(key) > 0) {
365  throw std::ios_base::failure("Duplicate Key, key for unknown value already provided");
366  }
367  // Read in the value
368  std::vector<unsigned char> val_bytes;
369  s >> val_bytes;
370  unknown.emplace(std::move(key), std::move(val_bytes));
371  break;
372  }
373  }
374  }
375 
376  if (!found_sep) {
377  throw std::ios_base::failure("Separator is missing at the end of an output map");
378  }
379  }
380 
381  template <typename Stream>
383  Unserialize(s);
384  }
385 };
386 
389 {
391  std::vector<PSBTInput> inputs;
392  std::vector<PSBTOutput> outputs;
393  std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown;
394 
395  bool IsNull() const;
396 
399  NODISCARD bool Merge(const PartiallySignedTransaction& psbt);
400  bool IsSane() const;
401  bool AddInput(const CTxIn& txin, PSBTInput& psbtin);
402  bool AddOutput(const CTxOut& txout, const PSBTOutput& psbtout);
412  bool GetInputUTXO(CTxOut& utxo, int input_index) const;
413 
414  template <typename Stream>
415  inline void Serialize(Stream& s) const {
416 
417  // magic bytes
418  s << PSBT_MAGIC_BYTES;
419 
420  // unsigned tx flag
422 
423  // Write serialized tx to a stream
424  OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
425  SerializeToVector(os, *tx);
426 
427  // Write the unknown things
428  for (auto& entry : unknown) {
429  s << entry.first;
430  s << entry.second;
431  }
432 
433  // Separator
434  s << PSBT_SEPARATOR;
435 
436  // Write inputs
437  for (const PSBTInput& input : inputs) {
438  s << input;
439  }
440  // Write outputs
441  for (const PSBTOutput& output : outputs) {
442  s << output;
443  }
444  }
445 
446 
447  template <typename Stream>
448  inline void Unserialize(Stream& s) {
449  // Read the magic bytes
450  uint8_t magic[5];
451  s >> magic;
452  if (!std::equal(magic, magic + 5, PSBT_MAGIC_BYTES)) {
453  throw std::ios_base::failure("Invalid PSBT magic bytes");
454  }
455 
456  // Used for duplicate key detection
457  std::set<std::vector<unsigned char>> key_lookup;
458 
459  // Read global data
460  bool found_sep = false;
461  while(!s.empty()) {
462  // Read
463  std::vector<unsigned char> key;
464  s >> key;
465 
466  // the key is empty if that was actually a separator byte
467  // This is a special case for key lengths 0 as those are not allowed (except for separator)
468  if (key.empty()) {
469  found_sep = true;
470  break;
471  }
472 
473  // First byte of key is the type
474  unsigned char type = key[0];
475 
476  // Do stuff based on type
477  switch(type) {
479  {
480  if (!key_lookup.emplace(key).second) {
481  throw std::ios_base::failure("Duplicate Key, unsigned tx already provided");
482  } else if (key.size() != 1) {
483  throw std::ios_base::failure("Global unsigned tx key is more than one byte type");
484  }
486  // Set the stream to serialize with non-witness since this should always be non-witness
487  OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
488  UnserializeFromVector(os, mtx);
489  tx = std::move(mtx);
490  // Make sure that all scriptSigs and scriptWitnesses are empty
491  for (const CTxIn& txin : tx->vin) {
492  if (!txin.scriptSig.empty() || !txin.scriptWitness.IsNull()) {
493  throw std::ios_base::failure("Unsigned tx does not have empty scriptSigs and scriptWitnesses.");
494  }
495  }
496  break;
497  }
498  // Unknown stuff
499  default: {
500  if (unknown.count(key) > 0) {
501  throw std::ios_base::failure("Duplicate Key, key for unknown value already provided");
502  }
503  // Read in the value
504  std::vector<unsigned char> val_bytes;
505  s >> val_bytes;
506  unknown.emplace(std::move(key), std::move(val_bytes));
507  }
508  }
509  }
510 
511  if (!found_sep) {
512  throw std::ios_base::failure("Separator is missing at the end of the global map");
513  }
514 
515  // Make sure that we got an unsigned tx
516  if (!tx) {
517  throw std::ios_base::failure("No unsigned transcation was provided");
518  }
519 
520  // Read input data
521  unsigned int i = 0;
522  while (!s.empty() && i < tx->vin.size()) {
523  PSBTInput input;
524  s >> input;
525  inputs.push_back(input);
526 
527  // Make sure the non-witness utxo matches the outpoint
528  if (input.non_witness_utxo && input.non_witness_utxo->GetHash() != tx->vin[i].prevout.hash) {
529  throw std::ios_base::failure("Non-witness UTXO does not match outpoint hash");
530  }
531  ++i;
532  }
533  // Make sure that the number of inputs matches the number of inputs in the transaction
534  if (inputs.size() != tx->vin.size()) {
535  throw std::ios_base::failure("Inputs provided does not match the number of inputs in transaction.");
536  }
537 
538  // Read output data
539  i = 0;
540  while (!s.empty() && i < tx->vout.size()) {
541  PSBTOutput output;
542  s >> output;
543  outputs.push_back(output);
544  ++i;
545  }
546  // Make sure that the number of outputs matches the number of outputs in the transaction
547  if (outputs.size() != tx->vout.size()) {
548  throw std::ios_base::failure("Outputs provided does not match the number of outputs in transaction.");
549  }
550  // Sanity check
551  if (!IsSane()) {
552  throw std::ios_base::failure("PSBT is not sane.");
553  }
554  }
555 
556  template <typename Stream>
558  Unserialize(s);
559  }
560 };
561 
562 enum class PSBTRole {
563  CREATOR,
564  UPDATER,
565  SIGNER,
566  FINALIZER,
567  EXTRACTOR
568 };
569 
570 std::string PSBTRoleName(PSBTRole role);
571 
573 bool PSBTInputSigned(const PSBTInput& input);
574 
576 bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index, int sighash = SIGHASH_ALL, SignatureData* out_sigdata = nullptr, bool use_dummy = false);
577 
582 void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index);
583 
591 
600 
608 NODISCARD TransactionError CombinePSBTs(PartiallySignedTransaction& out, const std::vector<PartiallySignedTransaction>& psbtxs);
609 
611 NODISCARD bool DecodeBase64PSBT(PartiallySignedTransaction& decoded_psbt, const std::string& base64_psbt, std::string& error);
613 NODISCARD bool DecodeRawPSBT(PartiallySignedTransaction& decoded_psbt, const std::string& raw_psbt, std::string& error);
614 
615 #endif // BITCOIN_PSBT_H
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:408
static const int SERIALIZE_TRANSACTION_NO_WITNESS
Definition: transaction.h:15
static constexpr unsigned int SIZE
secp256k1:
Definition: pubkey.h:36
void SerializeToVector(Stream &s, const X &... args)
Definition: sign.h:80
static constexpr uint8_t PSBT_SEPARATOR
Definition: psbt.h:41
static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT
Definition: psbt.h:35
Optional< CMutableTransaction > tx
Definition: psbt.h:390
std::vector< CTxIn > vin
Definition: transaction.h:368
CScriptWitness scriptWitness
Only serialized through CTransaction.
Definition: transaction.h:69
static constexpr uint8_t PSBT_IN_PARTIAL_SIG
Definition: psbt.h:26
static constexpr uint8_t PSBT_IN_SCRIPTWITNESS
Definition: psbt.h:32
PSBTInput(deserialize_type, Stream &s)
Definition: psbt.h:266
std::vector< std::vector< unsigned char > > stack
Definition: script.h:574
void Serialize(Stream &s) const
Definition: psbt.h:415
void FromSignatureData(const SignatureData &sigdata)
Definition: psbt.cpp:114
A version of CTransaction with the PSBT format.
Definition: psbt.h:388
CTxOut witness_utxo
Definition: psbt.h:47
bool IsNull() const
Definition: script.h:579
constexpr Span< A > MakeSpan(A(&a)[N])
Create a span to a container exposing data() and size().
Definition: span.h:55
void Serialize(Stream &s) const
Definition: psbt.h:287
void DeserializeHDKeypaths(Stream &s, const std::vector< unsigned char > &key, std::map< CPubKey, KeyOriginInfo > &hd_keypaths)
Definition: sign.h:101
NODISCARD bool DecodeRawPSBT(PartiallySignedTransaction &decoded_psbt, const std::string &raw_psbt, std::string &error)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
Definition: psbt.cpp:378
void Serialize(Stream &s) const
Definition: psbt.h:65
std::string PSBTRoleName(PSBTRole role)
Definition: psbt.cpp:355
CScript redeem_script
Definition: psbt.h:48
Dummy data type to identify deserializing constructors.
Definition: serialize.h:42
void UnserializeFromVector(Stream &s, X &... args)
Definition: sign.h:88
static constexpr uint8_t PSBT_IN_WITNESS_UTXO
Definition: psbt.h:25
void Merge(const PSBTInput &input)
Definition: psbt.cpp:143
static constexpr uint8_t PSBT_IN_BIP32_DERIVATION
Definition: psbt.h:30
bool IsNull() const
Definition: transaction.h:160
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
Definition: psbt.cpp:308
PSBTRole
Definition: psbt.h:562
A structure for PSBTs which contains per output information.
Definition: psbt.h:272
std::vector< PSBTOutput > outputs
Definition: psbt.h:392
std::map< CPubKey, KeyOriginInfo > hd_keypaths
Definition: psbt.h:276
static constexpr unsigned int COMPRESSED_SIZE
Definition: pubkey.h:37
NODISCARD bool DecodeBase64PSBT(PartiallySignedTransaction &decoded_psbt, const std::string &base64_psbt, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
Definition: psbt.cpp:367
An input of a transaction.
Definition: transaction.h:63
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
Definition: psbt.h:54
#define NODISCARD
Definition: attributes.h:18
static constexpr uint8_t PSBT_IN_SCRIPTSIG
Definition: psbt.h:31
std::map< CPubKey, KeyOriginInfo > hd_keypaths
Definition: psbt.h:52
std::map< CKeyID, SigPair > partial_sigs
Definition: psbt.h:53
An encapsulated public key.
Definition: pubkey.h:30
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, int sighash=SIGHASH_ALL, SignatureData *out_sigdata=nullptr, bool use_dummy=false)
Signs a PSBTInput, verifying that all provided data matches what is being signed. ...
Definition: psbt.cpp:236
std::pair< CPubKey, std::vector< unsigned char > > SigPair
Definition: sign.h:53
CScriptWitness final_script_witness
Definition: psbt.h:51
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
Definition: psbt.h:277
static constexpr uint8_t PSBT_IN_SIGHASH
Definition: psbt.h:27
A structure for PSBTs which contain per-input information.
Definition: psbt.h:44
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed.
Definition: psbt.cpp:212
void Unserialize(Stream &s)
Definition: psbt.h:448
An output of a transaction.
Definition: transaction.h:133
static constexpr uint8_t PSBT_IN_REDEEMSCRIPT
Definition: psbt.h:28
static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX
Definition: psbt.h:21
std::vector< CTxOut > vout
Definition: transaction.h:369
PSBTInput()
Definition: psbt.h:62
PSBTOutput()
Definition: psbt.h:284
std::vector< PSBTInput > inputs
Definition: psbt.h:391
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
Definition: psbt.cpp:217
int sighash_type
Definition: psbt.h:55
CScript scriptSig
Definition: transaction.h:67
static constexpr uint8_t PSBT_IN_WITNESSSCRIPT
Definition: psbt.h:29
bool IsSane() const
Definition: psbt.cpp:161
An interface to be implemented by keystores that support signing.
void SerializeHDKeypaths(Stream &s, const std::map< CPubKey, KeyOriginInfo > &hd_keypaths, uint8_t type)
Definition: sign.h:136
NODISCARD TransactionError CombinePSBTs(PartiallySignedTransaction &out, const std::vector< PartiallySignedTransaction > &psbtxs)
Combines PSBTs with the same underlying transaction, resulting in a single PSBT with all partial sign...
Definition: psbt.cpp:338
CScript witness_script
Definition: psbt.h:275
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:390
CScript redeem_script
Definition: psbt.h:274
bool empty() const
Definition: prevector.h:286
CTransactionRef non_witness_utxo
Definition: psbt.h:46
TransactionError
Definition: error.h:22
void Unserialize(Stream &s)
Definition: psbt.h:314
void Unserialize(Stream &s)
Definition: psbt.h:128
static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION
Definition: psbt.h:37
A mutable version of CTransaction.
Definition: transaction.h:366
PSBTOutput(deserialize_type, Stream &s)
Definition: psbt.h:382
static constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO
Definition: psbt.h:24
CScript final_script_sig
Definition: psbt.h:50
boost::optional< T > Optional
Substitute for C++17 std::optional.
Definition: optional.h:14
static constexpr uint8_t PSBT_OUT_WITNESSSCRIPT
Definition: psbt.h:36
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized...
Definition: psbt.cpp:322
void FillSignatureData(SignatureData &sigdata) const
Definition: psbt.cpp:88
CScript witness_script
Definition: psbt.h:49
PartiallySignedTransaction(deserialize_type, Stream &s)
Definition: psbt.h:557
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
Definition: psbt.h:393
static constexpr uint8_t PSBT_MAGIC_BYTES[5]
Definition: psbt.h:18
bool IsNull() const
Definition: psbt.cpp:83