22 if (
tx->GetId() != psbt.
tx->GetId()) {
26 for (
size_t i = 0; i <
inputs.size(); ++i) {
29 for (
size_t i = 0; i <
outputs.size(); ++i) {
39 if (std::find(
tx->vin.begin(),
tx->vin.end(), txin) !=
tx->vin.end()) {
42 tx->vin.push_back(txin);
51 tx->vout.push_back(txout);
57 int input_index)
const {
86 sigdata.
misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
133 sigdata.
misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
165 const CTxOut &out = psbt.
tx->vout.at(index);
177 psbt.
tx ? &psbt.
tx.value() :
nullptr, 0, out.
nValue,
209 bool sig_complete{
false};
222 if (out_sigdata !=
nullptr) {
237 bool complete =
true;
238 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
256 for (
size_t i = 0; i < result.
vin.size(); ++i) {
257 result.
vin[i].scriptSig = psbtx.
inputs[i].final_script_sig;
264 const std::vector<PartiallySignedTransaction> &psbtxs) {
269 for (
auto it = std::next(psbtxs.begin()); it != psbtxs.end(); ++it) {
270 if (!out.
Merge(*it)) {
296 const std::string &base64_tx, std::string &
error) {
298 std::string tx_data =
DecodeBase64(base64_tx, &invalid);
300 error =
"invalid base64";
307 std::string &
error) {
308 CDataStream ss_data(tx_data.data(), tx_data.data() + tx_data.size(),
312 if (!ss_data.
empty()) {
313 error =
"extra data after PSBT";
316 }
catch (
const std::exception &e) {
Double ended buffer combining vector and stream-like interfaces.
A mutable version of CTransaction.
std::vector< CTxOut > vout
An input of a transaction.
An output of a transaction.
A signature creator for transactions.
Signature hash type wrapper class.
An interface to be implemented by keystores that support signing.
bool DecodeRawPSBT(PartiallySignedTransaction &psbt, const std::string &tx_data, std::string &error)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
std::string PSBTRoleName(const PSBTRole role)
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed.
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...
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, SigHashType sighash, SignatureData *out_sigdata, bool use_dummy)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
const BaseSignatureCreator & DUMMY_SIGNATURE_CREATOR
A signature creator that just produces 71-byte empty signatures.
const SigningProvider & DUMMY_SIGNING_PROVIDER
std::vector< uint8_t > DecodeBase64(const char *p, bool *pf_invalid)
A structure for PSBTs which contains per output information.
void Merge(const PSBTOutput &output)
std::map< CPubKey, KeyOriginInfo > hd_keypaths
std::map< std::vector< uint8_t >, std::vector< uint8_t > > unknown
void FillSignatureData(SignatureData &sigdata) const
void FromSignatureData(const SignatureData &sigdata)
A version of CTransaction with the PSBT format.
bool Merge(const PartiallySignedTransaction &psbt)
Merge psbt into this.
PartiallySignedTransaction()
std::map< std::vector< uint8_t >, std::vector< uint8_t > > unknown
bool GetInputUTXO(CTxOut &utxo, int input_index) const
Finds the UTXO for a given input index.
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
std::vector< PSBTInput > inputs
std::optional< CMutableTransaction > tx
bool AddInput(const CTxIn &txin, PSBTInput &psbtin)
std::vector< PSBTOutput > outputs
uint160 missing_redeem_script
ScriptID of the missing redeemScript (if any)
std::vector< CKeyID > missing_sigs
KeyIDs of pubkeys for signatures which could not be found.
std::map< CKeyID, SigPair > signatures
BIP 174 style partial signatures for the input.
std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > misc_pubkeys
CScript scriptSig
The scriptSig of an input.
CScript redeem_script
The redeemScript (if any) for the input.
std::vector< CKeyID > missing_pubkeys
KeyIDs of pubkeys which could not be found.
bool complete
Stores whether the scriptSig are complete.
bool error(const char *fmt, const Args &...args)
static const int PROTOCOL_VERSION
network protocol versioning