mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-11 22:43:06 +02:00
Allow specifying PSBT version in constructor
The constructor will create the PSBT of the specified version, as long as it is 0 or 2.
This commit is contained in:
@@ -15,8 +15,10 @@
|
||||
|
||||
using common::PSBTError;
|
||||
|
||||
PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx)
|
||||
PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx, uint32_t version) : m_version(version)
|
||||
{
|
||||
assert(m_version == 0 || m_version == 2);
|
||||
|
||||
tx_version = tx.version;
|
||||
fallback_locktime = tx.nLockTime;
|
||||
inputs.reserve(tx.vin.size());
|
||||
|
||||
@@ -1259,7 +1259,7 @@ public:
|
||||
std::optional<uint32_t> ComputeTimeLock() const;
|
||||
std::optional<CMutableTransaction> GetUnsignedTx() const;
|
||||
std::optional<Txid> GetUniqueID() const;
|
||||
explicit PartiallySignedTransaction(const CMutableTransaction& tx);
|
||||
explicit PartiallySignedTransaction(const CMutableTransaction& tx, uint32_t version = 0);
|
||||
|
||||
template <typename Stream>
|
||||
inline void Serialize(Stream& s) const {
|
||||
|
||||
@@ -1876,7 +1876,7 @@ static RPCMethod joinpsbts()
|
||||
CMutableTransaction tx;
|
||||
tx.version = best_version;
|
||||
tx.nLockTime = best_locktime;
|
||||
PartiallySignedTransaction merged_psbt(tx);
|
||||
PartiallySignedTransaction merged_psbt(tx, psbtxs.at(0).GetVersion());
|
||||
|
||||
// Merge
|
||||
for (auto& psbt : psbtxs) {
|
||||
@@ -1908,7 +1908,7 @@ static RPCMethod joinpsbts()
|
||||
std::shuffle(input_indices.begin(), input_indices.end(), FastRandomContext());
|
||||
std::shuffle(output_indices.begin(), output_indices.end(), FastRandomContext());
|
||||
|
||||
PartiallySignedTransaction shuffled_psbt(tx);
|
||||
PartiallySignedTransaction shuffled_psbt(tx, merged_psbt.GetVersion());
|
||||
for (int i : input_indices) {
|
||||
shuffled_psbt.AddInput(merged_psbt.inputs[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user