23 if (
tx->GetHash() != psbt.
tx->GetHash()) {
27 for (
unsigned int i = 0; i <
inputs.size(); ++i) {
30 for (
unsigned int i = 0; i <
outputs.size(); ++i) {
40 if (std::find(
tx->vin.begin(),
tx->vin.end(), txin) !=
tx->vin.end()) {
43 tx->vin.push_back(txin);
53 tx->vout.push_back(txout);
61 uint32_t prevout_index =
tx->vin[input_index].prevout.n;
102 sigdata.
misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
162 sigdata.
misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
199 for (
const auto& input : psbt.
inputs) {
210 const CTxOut& out = psbt.
tx->vout.at(index);
241 bool require_witness_sig =
false;
260 require_witness_sig =
true;
274 if (require_witness_sig && !sigdata.
witness)
return false;
301 bool complete =
true;
302 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
318 for (
unsigned int i = 0; i < result.
vin.size(); ++i) {
319 result.
vin[i].scriptSig = psbtx.
inputs[i].final_script_sig;
320 result.
vin[i].scriptWitness = psbtx.
inputs[i].final_script_witness;
330 for (
auto it = std::next(psbtxs.begin());
it != psbtxs.end(); ++
it) {
353 std::string tx_data =
DecodeBase64(base64_tx, &invalid);
355 error =
"invalid base64";
366 if (!ss_data.empty()) {
367 error =
"extra data after PSBT";
370 }
catch (
const std::exception& e) {
bool AddInput(const CTxIn &txin, PSBTInput &psbtin)
bool GetInputUTXO(CTxOut &utxo, int input_index) const
Finds the UTXO for a given input index.
void FillSignatureData(SignatureData &sigdata) const
CScript witness_script
The witnessScript (if any) for the input. witnessScripts are used in P2WSH outputs.
Optional< CMutableTransaction > tx
CScript scriptSig
The scriptSig of an input. Contains complete signatures or the traditional partial signatures format...
std::vector< CKeyID > missing_sigs
KeyIDs of pubkeys for signatures which could not be found.
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, int sighash, SignatureData *out_sigdata, bool use_dummy)
Signs a PSBTInput, verifying that all provided data matches what is being signed. ...
std::vector< CKeyID > missing_pubkeys
KeyIDs of pubkeys which could not be found.
const BaseSignatureCreator & DUMMY_SIGNATURE_CREATOR
A signature creator that just produces 71-byte empty signatures.
void Merge(const PSBTOutput &output)
std::vector< unsigned char > DecodeBase64(const char *p, bool *pf_invalid)
A version of CTransaction with the PSBT format.
Double ended buffer combining vector and stream-like interfaces.
std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > misc_pubkeys
A signature creator for transactions.
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
uint256 missing_witness_script
SHA256 of the missing witnessScript (if any)
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized...
void FromSignatureData(const SignatureData &sigdata)
std::string PSBTRoleName(PSBTRole role)
A structure for PSBTs which contains per output information.
std::vector< PSBTOutput > outputs
std::map< CPubKey, KeyOriginInfo > hd_keypaths
uint160 missing_redeem_script
ScriptID of the missing redeemScript (if any)
bool error(const char *fmt, const Args &...args)
An input of a transaction.
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
const SigningProvider & DUMMY_SIGNING_PROVIDER
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
An output of a transaction.
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
std::vector< PSBTInput > inputs
CScriptWitness scriptWitness
The scriptWitness of an input. Contains complete signatures or the traditional partial signatures for...
size_t CountPSBTUnsignedInputs(const PartiallySignedTransaction &psbt)
Counts the unsigned inputs of a PSBT.
bool DecodeRawPSBT(PartiallySignedTransaction &psbt, const std::string &tx_data, std::string &error)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
NODISCARD bool Merge(const PartiallySignedTransaction &psbt)
Merge psbt into this.
An interface to be implemented by keystores that support signing.
static const int PROTOCOL_VERSION
network protocol versioning
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
A mutable version of CTransaction.
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed.
bool complete
Stores whether the scriptSig and scriptWitness are complete.
CScript redeem_script
The redeemScript (if any) for the input.
PartiallySignedTransaction()
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
bool witness
Stores whether the input this SigData corresponds to is a witness input.
std::map< CKeyID, SigPair > signatures
BIP 174 style partial signatures for the input. May contain all signatures necessary for producing a ...
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...