aboutsummaryrefslogtreecommitdiff
path: root/src/psbt.h
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2023-09-07 19:16:57 +1000
committerAnthony Towns <aj@erisian.com.au>2023-11-14 08:45:30 +1000
commit6e9e4e6130797b721c8df1eabaf46ec25ebb6abe (patch)
tree6444c337cd23d1e6aabedf229a9efb1583fb7351 /src/psbt.h
parent5800c558eb5efb4839ed00d6967e43306d68e1c3 (diff)
downloadbitcoin-6e9e4e6130797b721c8df1eabaf46ec25ebb6abe.tar.xz
Use ParamsWrapper for witness serialization
Diffstat (limited to 'src/psbt.h')
-rw-r--r--src/psbt.h14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/psbt.h b/src/psbt.h
index 5b4daafed5..1fd186f6a5 100644
--- a/src/psbt.h
+++ b/src/psbt.h
@@ -95,7 +95,7 @@ void SerializeToVector(Stream& s, const X&... args)
// Takes a stream and multiple arguments and unserializes them first as a vector then each object individually in the order provided in the arguments
template<typename Stream, typename... X>
-void UnserializeFromVector(Stream& s, X&... args)
+void UnserializeFromVector(Stream& s, X&&... args)
{
size_t expected_size = ReadCompactSize(s);
size_t remaining_before = s.size();
@@ -226,8 +226,7 @@ struct PSBTInput
// Write the utxo
if (non_witness_utxo) {
SerializeToVector(s, CompactSizeWriter(PSBT_IN_NON_WITNESS_UTXO));
- OverrideStream<Stream> os{&s, s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS};
- SerializeToVector(os, non_witness_utxo);
+ SerializeToVector(s, TX_NO_WITNESS(non_witness_utxo));
}
if (!witness_utxo.IsNull()) {
SerializeToVector(s, CompactSizeWriter(PSBT_IN_WITNESS_UTXO));
@@ -394,8 +393,7 @@ struct PSBTInput
throw std::ios_base::failure("Non-witness utxo key is more than one byte type");
}
// Set the stream to unserialize with witness since this is always a valid network transaction
- OverrideStream<Stream> os{&s, s.GetVersion() & ~SERIALIZE_TRANSACTION_NO_WITNESS};
- UnserializeFromVector(os, non_witness_utxo);
+ UnserializeFromVector(s, TX_WITH_WITNESS(non_witness_utxo));
break;
}
case PSBT_IN_WITNESS_UTXO:
@@ -984,8 +982,7 @@ struct PartiallySignedTransaction
SerializeToVector(s, CompactSizeWriter(PSBT_GLOBAL_UNSIGNED_TX));
// Write serialized tx to a stream
- OverrideStream<Stream> os{&s, s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS};
- SerializeToVector(os, *tx);
+ SerializeToVector(s, TX_NO_WITNESS(*tx));
// Write xpubs
for (const auto& xpub_pair : m_xpubs) {
@@ -1075,8 +1072,7 @@ struct PartiallySignedTransaction
}
CMutableTransaction mtx;
// Set the stream to serialize with non-witness since this should always be non-witness
- OverrideStream<Stream> os{&s, s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS};
- UnserializeFromVector(os, mtx);
+ UnserializeFromVector(s, TX_NO_WITNESS(mtx));
tx = std::move(mtx);
// Make sure that all scriptSigs and scriptWitnesses are empty
for (const CTxIn& txin : tx->vin) {