Changeset View
Changeset View
Standalone View
Standalone View
src/psbt.cpp
// Copyright (c) 2009-2018 The Bitcoin Core developers | // Copyright (c) 2009-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <psbt.h> | #include <psbt.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
PartiallySignedTransaction::PartiallySignedTransaction( | PartiallySignedTransaction::PartiallySignedTransaction( | ||||
const CMutableTransaction &txIn) | const CMutableTransaction &txIn) | ||||
: tx(txIn) { | : tx(txIn) { | ||||
inputs.resize(txIn.vin.size()); | inputs.resize(txIn.vin.size()); | ||||
outputs.resize(txIn.vout.size()); | outputs.resize(txIn.vout.size()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | void UpdatePSBTOutput(const SigningProvider &provider, | ||||
// Fill a SignatureData with output info | // Fill a SignatureData with output info | ||||
SignatureData sigdata; | SignatureData sigdata; | ||||
psbt_out.FillSignatureData(sigdata); | psbt_out.FillSignatureData(sigdata); | ||||
// Construct a would-be spend of this output, to update sigdata with. | // Construct a would-be spend of this output, to update sigdata with. | ||||
// Note that ProduceSignature is used to fill in metadata (not actual | // Note that ProduceSignature is used to fill in metadata (not actual | ||||
// signatures), so provider does not need to provide any private keys (it | // signatures), so provider does not need to provide any private keys (it | ||||
// can be a HidingSigningProvider). | // can be a HidingSigningProvider). | ||||
MutableTransactionSignatureCreator creator(psbt.tx.get_ptr(), /* index */ 0, | MutableTransactionSignatureCreator creator( | ||||
out.nValue, | psbt.tx ? &psbt.tx.value() : nullptr, /* index */ 0, out.nValue, | ||||
deadalnix: Why not use value_or here ? | |||||
majcostaAuthorUnsubmitted Done Inline Actionsit would work if psbt.tx was a std::optional<CMutableTransaction*> instead of a std::optional<CMutableTransaction>. since MutableTransactionSignatureCreator's ctor takes a const CMutableTransaction* parameter, this is needed to preserve original behavior using Boost:optional::get_ptr(): Returns: If *this is initialized, a pointer to the contained value; else 0 (null). currently using psbt.tx.value_or(nullptr) doesn't work because is_convertible_v<nullptr_t &&,CMutableTransaction> fails. majcosta: it would work if `psbt.tx` was a `std::optional<CMutableTransaction*>` instead of a `std… | |||||
SigHashType().withForkId()); | SigHashType().withForkId()); | ||||
ProduceSignature(provider, creator, out.scriptPubKey, sigdata); | ProduceSignature(provider, creator, out.scriptPubKey, sigdata); | ||||
// Put redeem_script and key paths, into PSBTOutput. | // Put redeem_script and key paths, into PSBTOutput. | ||||
psbt_out.FromSignatureData(sigdata); | psbt_out.FromSignatureData(sigdata); | ||||
} | } | ||||
bool SignPSBTInput(const SigningProvider &provider, | bool SignPSBTInput(const SigningProvider &provider, | ||||
PartiallySignedTransaction &psbt, int index, | PartiallySignedTransaction &psbt, int index, | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |
Why not use value_or here ?