Bitcoin Core  22.99.0
P2P Digital Currency
psbt.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2021 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 #include <psbt.h>
6 
7 #include <util/check.h>
8 #include <util/strencodings.h>
9 
10 
12 {
13  inputs.resize(tx.vin.size());
14  outputs.resize(tx.vout.size());
15 }
16 
18 {
19  return !tx && inputs.empty() && outputs.empty() && unknown.empty();
20 }
21 
23 {
24  // Prohibited to merge two PSBTs over different transactions
25  if (tx->GetHash() != psbt.tx->GetHash()) {
26  return false;
27  }
28 
29  for (unsigned int i = 0; i < inputs.size(); ++i) {
30  inputs[i].Merge(psbt.inputs[i]);
31  }
32  for (unsigned int i = 0; i < outputs.size(); ++i) {
33  outputs[i].Merge(psbt.outputs[i]);
34  }
35  for (auto& xpub_pair : psbt.m_xpubs) {
36  if (m_xpubs.count(xpub_pair.first) == 0) {
37  m_xpubs[xpub_pair.first] = xpub_pair.second;
38  } else {
39  m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end());
40  }
41  }
42  unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
43 
44  return true;
45 }
46 
48 {
49  if (std::find(tx->vin.begin(), tx->vin.end(), txin) != tx->vin.end()) {
50  return false;
51  }
52  tx->vin.push_back(txin);
53  psbtin.partial_sigs.clear();
54  psbtin.final_script_sig.clear();
56  inputs.push_back(psbtin);
57  return true;
58 }
59 
60 bool PartiallySignedTransaction::AddOutput(const CTxOut& txout, const PSBTOutput& psbtout)
61 {
62  tx->vout.push_back(txout);
63  outputs.push_back(psbtout);
64  return true;
65 }
66 
67 bool PartiallySignedTransaction::GetInputUTXO(CTxOut& utxo, int input_index) const
68 {
69  const PSBTInput& input = inputs[input_index];
70  uint32_t prevout_index = tx->vin[input_index].prevout.n;
71  if (input.non_witness_utxo) {
72  if (prevout_index >= input.non_witness_utxo->vout.size()) {
73  return false;
74  }
75  if (input.non_witness_utxo->GetHash() != tx->vin[input_index].prevout.hash) {
76  return false;
77  }
78  utxo = input.non_witness_utxo->vout[prevout_index];
79  } else if (!input.witness_utxo.IsNull()) {
80  utxo = input.witness_utxo;
81  } else {
82  return false;
83  }
84  return true;
85 }
86 
87 bool PSBTInput::IsNull() const
88 {
89  return !non_witness_utxo && witness_utxo.IsNull() && partial_sigs.empty() && unknown.empty() && hd_keypaths.empty() && redeem_script.empty() && witness_script.empty();
90 }
91 
93 {
94  if (!final_script_sig.empty()) {
95  sigdata.scriptSig = final_script_sig;
96  sigdata.complete = true;
97  }
100  sigdata.complete = true;
101  }
102  if (sigdata.complete) {
103  return;
104  }
105 
106  sigdata.signatures.insert(partial_sigs.begin(), partial_sigs.end());
107  if (!redeem_script.empty()) {
108  sigdata.redeem_script = redeem_script;
109  }
110  if (!witness_script.empty()) {
111  sigdata.witness_script = witness_script;
112  }
113  for (const auto& key_pair : hd_keypaths) {
114  sigdata.misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
115  }
116 }
117 
119 {
120  if (sigdata.complete) {
121  partial_sigs.clear();
122  hd_keypaths.clear();
125 
126  if (!sigdata.scriptSig.empty()) {
127  final_script_sig = sigdata.scriptSig;
128  }
129  if (!sigdata.scriptWitness.IsNull()) {
131  }
132  return;
133  }
134 
135  partial_sigs.insert(sigdata.signatures.begin(), sigdata.signatures.end());
136  if (redeem_script.empty() && !sigdata.redeem_script.empty()) {
137  redeem_script = sigdata.redeem_script;
138  }
139  if (witness_script.empty() && !sigdata.witness_script.empty()) {
140  witness_script = sigdata.witness_script;
141  }
142  for (const auto& entry : sigdata.misc_pubkeys) {
143  hd_keypaths.emplace(entry.second);
144  }
145 }
146 
147 void PSBTInput::Merge(const PSBTInput& input)
148 {
150  if (witness_utxo.IsNull() && !input.witness_utxo.IsNull()) {
151  // TODO: For segwit v1, we will want to clear out the non-witness utxo when setting a witness one. For v0 and non-segwit, this is not safe
152  witness_utxo = input.witness_utxo;
153  }
154 
155  partial_sigs.insert(input.partial_sigs.begin(), input.partial_sigs.end());
156  ripemd160_preimages.insert(input.ripemd160_preimages.begin(), input.ripemd160_preimages.end());
157  sha256_preimages.insert(input.sha256_preimages.begin(), input.sha256_preimages.end());
158  hash160_preimages.insert(input.hash160_preimages.begin(), input.hash160_preimages.end());
159  hash256_preimages.insert(input.hash256_preimages.begin(), input.hash256_preimages.end());
160  hd_keypaths.insert(input.hd_keypaths.begin(), input.hd_keypaths.end());
161  unknown.insert(input.unknown.begin(), input.unknown.end());
162 
167 }
168 
170 {
171  if (!redeem_script.empty()) {
172  sigdata.redeem_script = redeem_script;
173  }
174  if (!witness_script.empty()) {
175  sigdata.witness_script = witness_script;
176  }
177  for (const auto& key_pair : hd_keypaths) {
178  sigdata.misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
179  }
180 }
181 
183 {
184  if (redeem_script.empty() && !sigdata.redeem_script.empty()) {
185  redeem_script = sigdata.redeem_script;
186  }
187  if (witness_script.empty() && !sigdata.witness_script.empty()) {
188  witness_script = sigdata.witness_script;
189  }
190  for (const auto& entry : sigdata.misc_pubkeys) {
191  hd_keypaths.emplace(entry.second);
192  }
193 }
194 
195 bool PSBTOutput::IsNull() const
196 {
197  return redeem_script.empty() && witness_script.empty() && hd_keypaths.empty() && unknown.empty();
198 }
199 
200 void PSBTOutput::Merge(const PSBTOutput& output)
201 {
202  hd_keypaths.insert(output.hd_keypaths.begin(), output.hd_keypaths.end());
203  unknown.insert(output.unknown.begin(), output.unknown.end());
204 
205  if (redeem_script.empty() && !output.redeem_script.empty()) redeem_script = output.redeem_script;
207 }
208 bool PSBTInputSigned(const PSBTInput& input)
209 {
210  return !input.final_script_sig.empty() || !input.final_script_witness.IsNull();
211 }
212 
214  size_t count = 0;
215  for (const auto& input : psbt.inputs) {
216  if (!PSBTInputSigned(input)) {
217  count++;
218  }
219  }
220 
221  return count;
222 }
223 
224 void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index)
225 {
226  CMutableTransaction& tx = *Assert(psbt.tx);
227  const CTxOut& out = tx.vout.at(index);
228  PSBTOutput& psbt_out = psbt.outputs.at(index);
229 
230  // Fill a SignatureData with output info
231  SignatureData sigdata;
232  psbt_out.FillSignatureData(sigdata);
233 
234  // Construct a would-be spend of this output, to update sigdata with.
235  // Note that ProduceSignature is used to fill in metadata (not actual signatures),
236  // so provider does not need to provide any private keys (it can be a HidingSigningProvider).
237  MutableTransactionSignatureCreator creator(&tx, /*input_idx=*/0, out.nValue, SIGHASH_ALL);
238  ProduceSignature(provider, creator, out.scriptPubKey, sigdata);
239 
240  // Put redeem_script, witness_script, key paths, into PSBTOutput.
241  psbt_out.FromSignatureData(sigdata);
242 }
243 
245 {
246  const CMutableTransaction& tx = *psbt.tx;
247  bool have_all_spent_outputs = true;
248  std::vector<CTxOut> utxos(tx.vin.size());
249  for (size_t idx = 0; idx < tx.vin.size(); ++idx) {
250  if (!psbt.GetInputUTXO(utxos[idx], idx)) have_all_spent_outputs = false;
251  }
253  if (have_all_spent_outputs) {
254  txdata.Init(tx, std::move(utxos), true);
255  } else {
256  txdata.Init(tx, {}, true);
257  }
258  return txdata;
259 }
260 
261 bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index, const PrecomputedTransactionData* txdata, int sighash, SignatureData* out_sigdata, bool finalize)
262 {
263  PSBTInput& input = psbt.inputs.at(index);
264  const CMutableTransaction& tx = *psbt.tx;
265 
266  if (PSBTInputSigned(input)) {
267  return true;
268  }
269 
270  // Fill SignatureData with input info
271  SignatureData sigdata;
272  input.FillSignatureData(sigdata);
273 
274  // Get UTXO
275  bool require_witness_sig = false;
276  CTxOut utxo;
277 
278  if (input.non_witness_utxo) {
279  // If we're taking our information from a non-witness UTXO, verify that it matches the prevout.
280  COutPoint prevout = tx.vin[index].prevout;
281  if (prevout.n >= input.non_witness_utxo->vout.size()) {
282  return false;
283  }
284  if (input.non_witness_utxo->GetHash() != prevout.hash) {
285  return false;
286  }
287  utxo = input.non_witness_utxo->vout[prevout.n];
288  } else if (!input.witness_utxo.IsNull()) {
289  utxo = input.witness_utxo;
290  // When we're taking our information from a witness UTXO, we can't verify it is actually data from
291  // the output being spent. This is safe in case a witness signature is produced (which includes this
292  // information directly in the hash), but not for non-witness signatures. Remember that we require
293  // a witness signature in this situation.
294  require_witness_sig = true;
295  } else {
296  return false;
297  }
298 
299  sigdata.witness = false;
300  bool sig_complete;
301  if (txdata == nullptr) {
302  sig_complete = ProduceSignature(provider, DUMMY_SIGNATURE_CREATOR, utxo.scriptPubKey, sigdata);
303  } else {
304  MutableTransactionSignatureCreator creator(&tx, index, utxo.nValue, txdata, sighash);
305  sig_complete = ProduceSignature(provider, creator, utxo.scriptPubKey, sigdata);
306  }
307  // Verify that a witness signature was produced in case one was required.
308  if (require_witness_sig && !sigdata.witness) return false;
309 
310  // If we are not finalizing, set sigdata.complete to false to not set the scriptWitness
311  if (!finalize && sigdata.complete) sigdata.complete = false;
312 
313  input.FromSignatureData(sigdata);
314 
315  // If we have a witness signature, put a witness UTXO.
316  // TODO: For segwit v1, we should remove the non_witness_utxo
317  if (sigdata.witness) {
318  input.witness_utxo = utxo;
319  // input.non_witness_utxo = nullptr;
320  }
321 
322  // Fill in the missing info
323  if (out_sigdata) {
324  out_sigdata->missing_pubkeys = sigdata.missing_pubkeys;
325  out_sigdata->missing_sigs = sigdata.missing_sigs;
326  out_sigdata->missing_redeem_script = sigdata.missing_redeem_script;
327  out_sigdata->missing_witness_script = sigdata.missing_witness_script;
328  }
329 
330  return sig_complete;
331 }
332 
334 {
335  // Finalize input signatures -- in case we have partial signatures that add up to a complete
336  // signature, but have not combined them yet (e.g. because the combiner that created this
337  // PartiallySignedTransaction did not understand them), this will combine them into a final
338  // script.
339  bool complete = true;
340  const PrecomputedTransactionData txdata = PrecomputePSBTData(psbtx);
341  for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) {
342  complete &= SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, SIGHASH_ALL, nullptr, true);
343  }
344 
345  return complete;
346 }
347 
349 {
350  // It's not safe to extract a PSBT that isn't finalized, and there's no easy way to check
351  // whether a PSBT is finalized without finalizing it, so we just do this.
352  if (!FinalizePSBT(psbtx)) {
353  return false;
354  }
355 
356  result = *psbtx.tx;
357  for (unsigned int i = 0; i < result.vin.size(); ++i) {
358  result.vin[i].scriptSig = psbtx.inputs[i].final_script_sig;
359  result.vin[i].scriptWitness = psbtx.inputs[i].final_script_witness;
360  }
361  return true;
362 }
363 
364 TransactionError CombinePSBTs(PartiallySignedTransaction& out, const std::vector<PartiallySignedTransaction>& psbtxs)
365 {
366  out = psbtxs[0]; // Copy the first one
367 
368  // Merge
369  for (auto it = std::next(psbtxs.begin()); it != psbtxs.end(); ++it) {
370  if (!out.Merge(*it)) {
372  }
373  }
374  return TransactionError::OK;
375 }
376 
377 std::string PSBTRoleName(PSBTRole role) {
378  switch (role) {
379  case PSBTRole::CREATOR: return "creator";
380  case PSBTRole::UPDATER: return "updater";
381  case PSBTRole::SIGNER: return "signer";
382  case PSBTRole::FINALIZER: return "finalizer";
383  case PSBTRole::EXTRACTOR: return "extractor";
384  // no default case, so the compiler can warn about missing cases
385  }
386  assert(false);
387 }
388 
389 bool DecodeBase64PSBT(PartiallySignedTransaction& psbt, const std::string& base64_tx, std::string& error)
390 {
391  bool invalid;
392  std::string tx_data = DecodeBase64(base64_tx, &invalid);
393  if (invalid) {
394  error = "invalid base64";
395  return false;
396  }
397  return DecodeRawPSBT(psbt, tx_data, error);
398 }
399 
400 bool DecodeRawPSBT(PartiallySignedTransaction& psbt, const std::string& tx_data, std::string& error)
401 {
403  try {
404  ss_data >> psbt;
405  if (!ss_data.empty()) {
406  error = "extra data after PSBT";
407  return false;
408  }
409  } catch (const std::exception& e) {
410  error = e.what();
411  return false;
412  }
413  return true;
414 }
415 
417 {
418  if (m_version != std::nullopt) {
419  return *m_version;
420  }
421  return 0;
422 }
CTxIn
An input of a transaction.
Definition: transaction.h:65
CMutableTransaction::vin
std::vector< CTxIn > vin
Definition: transaction.h:346
CScriptWitness::IsNull
bool IsNull() const
Definition: script.h:566
PartiallySignedTransaction::GetVersion
uint32_t GetVersion() const
Definition: psbt.cpp:416
CombinePSBTs
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:364
FinalizePSBT
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
Definition: psbt.cpp:333
PSBTInput::non_witness_utxo
CTransactionRef non_witness_utxo
Definition: psbt.h:170
MakeUCharSpan
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(Span
Like the Span constructor, but for (const) unsigned char member types only.
Definition: span.h:280
PSBTInput::partial_sigs
std::map< CKeyID, SigPair > partial_sigs
Definition: psbt.h:177
count
static int count
Definition: tests.c:31
assert
assert(!tx.IsCoinBase())
SignatureData::missing_redeem_script
uint160 missing_redeem_script
ScriptID of the missing redeemScript (if any)
Definition: sign.h:77
SignPSBTInput
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, const PrecomputedTransactionData *txdata, int sighash, SignatureData *out_sigdata, bool finalize)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
Definition: psbt.cpp:261
check.h
SignatureData::scriptWitness
CScriptWitness scriptWitness
The scriptWitness of an input. Contains complete signatures or the traditional partial signatures for...
Definition: sign.h:69
DUMMY_SIGNATURE_CREATOR
const BaseSignatureCreator & DUMMY_SIGNATURE_CREATOR
A signature creator that just produces 71-byte empty signatures.
Definition: sign.cpp:580
PartiallySignedTransaction::IsNull
bool IsNull() const
Definition: psbt.cpp:17
COutPoint::hash
uint256 hash
Definition: transaction.h:29
PSBTOutput::FillSignatureData
void FillSignatureData(SignatureData &sigdata) const
Definition: psbt.cpp:169
PSBTRole::UPDATER
@ UPDATER
PartiallySignedTransaction::inputs
std::vector< PSBTInput > inputs
Definition: psbt.h:674
PSBTInput::witness_script
CScript witness_script
Definition: psbt.h:173
PartiallySignedTransaction::AddInput
bool AddInput(const CTxIn &txin, PSBTInput &psbtin)
Definition: psbt.cpp:47
SigningProvider
An interface to be implemented by keystores that support signing.
Definition: signingprovider.h:17
MutableTransactionSignatureCreator
A signature creator for transactions.
Definition: sign.h:37
PSBTOutput::redeem_script
CScript redeem_script
Definition: psbt.h:533
TransactionError::PSBT_MISMATCH
@ PSBT_MISMATCH
PSBTInput::hash256_preimages
std::map< uint256, std::vector< unsigned char > > hash256_preimages
Definition: psbt.h:181
FinalizeAndExtractPSBT
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:348
PartiallySignedTransaction::m_version
std::optional< uint32_t > m_version
Definition: psbt.h:677
DUMMY_SIGNING_PROVIDER
const SigningProvider & DUMMY_SIGNING_PROVIDER
Definition: signingprovider.cpp:12
PSBTOutput::witness_script
CScript witness_script
Definition: psbt.h:534
CScript::clear
void clear()
Definition: script.h:549
Assert
#define Assert(val)
Identity function.
Definition: check.h:57
DecodeBase64PSBT
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
Definition: psbt.cpp:389
CTxOut::nValue
CAmount nValue
Definition: transaction.h:131
strencodings.h
CTxOut::IsNull
bool IsNull() const
Definition: transaction.h:149
TransactionError
TransactionError
Definition: error.h:22
PartiallySignedTransaction::PartiallySignedTransaction
PartiallySignedTransaction()
Definition: psbt.h:688
PSBTInput::final_script_sig
CScript final_script_sig
Definition: psbt.h:174
SignatureData
Definition: sign.h:63
PartiallySignedTransaction::Merge
bool Merge(const PartiallySignedTransaction &psbt)
Merge psbt into this.
Definition: psbt.cpp:22
PSBTInput::hd_keypaths
std::map< CPubKey, KeyOriginInfo > hd_keypaths
Definition: psbt.h:176
CTxOut
An output of a transaction.
Definition: transaction.h:128
PSBTRole::SIGNER
@ SIGNER
CTxOut::scriptPubKey
CScript scriptPubKey
Definition: transaction.h:132
PartiallySignedTransaction::GetInputUTXO
bool GetInputUTXO(CTxOut &utxo, int input_index) const
Finds the UTXO for a given input index.
Definition: psbt.cpp:67
DecodeBase64
std::vector< unsigned char > DecodeBase64(const char *p, bool *pf_invalid)
Definition: strencodings.cpp:142
PrecomputedTransactionData::Init
void Init(const T &tx, std::vector< CTxOut > &&spent_outputs, bool force=false)
Initialize this PrecomputedTransactionData with transaction data.
Definition: interpreter.cpp:1423
PSBTInput::final_script_witness
CScriptWitness final_script_witness
Definition: psbt.h:175
PSBTRole::CREATOR
@ CREATOR
SignatureData::redeem_script
CScript redeem_script
The redeemScript (if any) for the input.
Definition: sign.h:67
PSBTOutput::IsNull
bool IsNull() const
Definition: psbt.cpp:195
SignatureData::scriptSig
CScript scriptSig
The scriptSig of an input. Contains complete signatures or the traditional partial signatures format.
Definition: sign.h:66
SignatureData::witness
bool witness
Stores whether the input this SigData corresponds to is a witness input.
Definition: sign.h:65
PartiallySignedTransaction::tx
std::optional< CMutableTransaction > tx
Definition: psbt.h:670
PSBTInput::Merge
void Merge(const PSBTInput &input)
Definition: psbt.cpp:147
SignatureData::signatures
std::map< CKeyID, SigPair > signatures
BIP 174 style partial signatures for the input. May contain all signatures necessary for producing a ...
Definition: sign.h:71
UpdatePSBTOutput
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
Definition: psbt.cpp:224
SignatureData::missing_sigs
std::vector< CKeyID > missing_sigs
KeyIDs of pubkeys for signatures which could not be found.
Definition: sign.h:76
SignatureData::witness_script
CScript witness_script
The witnessScript (if any) for the input. witnessScripts are used in P2WSH outputs.
Definition: sign.h:68
PSBTOutput
A structure for PSBTs which contains per output information.
Definition: psbt.h:531
PrecomputedTransactionData
Definition: interpreter.h:150
PartiallySignedTransaction::m_xpubs
std::map< KeyOriginInfo, std::set< CExtPubKey > > m_xpubs
Definition: psbt.h:673
SignatureData::complete
bool complete
Stores whether the scriptSig and scriptWitness are complete.
Definition: sign.h:64
PSBTInput::unknown
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
Definition: psbt.h:182
PartiallySignedTransaction::AddOutput
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
Definition: psbt.cpp:60
PSBTRole::EXTRACTOR
@ EXTRACTOR
PSBTRoleName
std::string PSBTRoleName(PSBTRole role)
Definition: psbt.cpp:377
DecodeRawPSBT
bool DecodeRawPSBT(PartiallySignedTransaction &psbt, const std::string &tx_data, std::string &error)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
Definition: psbt.cpp:400
CountPSBTUnsignedInputs
size_t CountPSBTUnsignedInputs(const PartiallySignedTransaction &psbt)
Counts the unsigned inputs of a PSBT.
Definition: psbt.cpp:213
ProduceSignature
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
Definition: sign.cpp:333
SignatureData::missing_pubkeys
std::vector< CKeyID > missing_pubkeys
KeyIDs of pubkeys which could not be found.
Definition: sign.h:75
CMutableTransaction::vout
std::vector< CTxOut > vout
Definition: transaction.h:347
PSBTInput::FillSignatureData
void FillSignatureData(SignatureData &sigdata) const
Definition: psbt.cpp:92
PSBTOutput::Merge
void Merge(const PSBTOutput &output)
Definition: psbt.cpp:200
SIGHASH_ALL
@ SIGHASH_ALL
Definition: interpreter.h:27
PSBTInput
A structure for PSBTs which contain per-input information.
Definition: psbt.h:168
PSBTRole::FINALIZER
@ FINALIZER
CScriptWitness::SetNull
void SetNull()
Definition: script.h:568
PSBTInput::FromSignatureData
void FromSignatureData(const SignatureData &sigdata)
Definition: psbt.cpp:118
PSBTInput::hash160_preimages
std::map< uint160, std::vector< unsigned char > > hash160_preimages
Definition: psbt.h:180
COutPoint::n
uint32_t n
Definition: transaction.h:30
SignatureData::misc_pubkeys
std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > misc_pubkeys
Definition: sign.h:72
PartiallySignedTransaction
A version of CTransaction with the PSBT format.
Definition: psbt.h:668
TransactionError::OK
@ OK
No error.
PSBTRole
PSBTRole
Definition: psbt.h:930
PartiallySignedTransaction::outputs
std::vector< PSBTOutput > outputs
Definition: psbt.h:675
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:184
PSBTInputSigned
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed.
Definition: psbt.cpp:208
PSBTInput::ripemd160_preimages
std::map< uint160, std::vector< unsigned char > > ripemd160_preimages
Definition: psbt.h:178
prevector::empty
bool empty() const
Definition: prevector.h:286
SER_NETWORK
@ SER_NETWORK
Definition: serialize.h:138
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
PSBTInput::redeem_script
CScript redeem_script
Definition: psbt.h:172
CDataStream::empty
bool empty() const
Definition: streams.h:236
SignatureData::missing_witness_script
uint256 missing_witness_script
SHA256 of the missing witnessScript (if any)
Definition: sign.h:78
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
PSBTInput::IsNull
bool IsNull() const
Definition: psbt.cpp:87
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:344
PSBTInput::sha256_preimages
std::map< uint256, std::vector< unsigned char > > sha256_preimages
Definition: psbt.h:179
PSBTOutput::FromSignatureData
void FromSignatureData(const SignatureData &sigdata)
Definition: psbt.cpp:182
PSBTInput::witness_utxo
CTxOut witness_utxo
Definition: psbt.h:171
PrecomputePSBTData
PrecomputedTransactionData PrecomputePSBTData(const PartiallySignedTransaction &psbt)
Compute a PrecomputedTransactionData object from a psbt.
Definition: psbt.cpp:244
PSBTOutput::hd_keypaths
std::map< CPubKey, KeyOriginInfo > hd_keypaths
Definition: psbt.h:535
PartiallySignedTransaction::unknown
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
Definition: psbt.h:676
PSBTOutput::unknown
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
Definition: psbt.h:536
PROTOCOL_VERSION
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:12
psbt.h