23 if (
tx->GetId() != psbt.
tx->GetId()) {
27 for (
size_t i = 0; i <
inputs.size(); ++i) {
30 for (
size_t 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);
52 tx->vout.push_back(txout);
58 int input_index)
const {
87 sigdata.
misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
134 sigdata.
misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
210 bool sig_complete{
false};
223 if (out_sigdata !=
nullptr) {
238 bool complete =
true;
239 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
257 for (
size_t i = 0; i < result.
vin.size(); ++i) {
258 result.
vin[i].scriptSig = psbtx.
inputs[i].final_script_sig;
265 const std::vector<PartiallySignedTransaction> &psbtxs) {
270 for (
auto it = std::next(psbtxs.begin()); it != psbtxs.end(); ++it) {
271 if (!out.
Merge(*it)) {
297 const std::string &base64_tx, std::string &
error) {
300 error =
"invalid base64";
311 if (!ss_data.
empty()) {
312 error =
"extra data after PSBT";
315 }
catch (
const std::exception &e) {
#define Assert(val)
Identity function.
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.
A Span is an object that can refer to a contiguous sequence of objects.
bool error(const char *fmt, const Args &...args)
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 DecodeRawPSBT(PartiallySignedTransaction &psbt, Span< const std::byte > tx_data, std::string &error)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
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
Span< const std::byte > MakeByteSpan(V &&v) noexcept
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.
std::optional< std::vector< uint8_t > > DecodeBase64(std::string_view str)
static const int PROTOCOL_VERSION
network protocol versioning