MCPcopy Create free account
hub / github.com/ElementsProject/elements / FillPSBT

Method FillPSBT

src/wallet/external_signer_scriptpubkeyman.cpp:64–85  ·  view source on GitHub ↗

If sign is true, transaction must previously have been filled

Source from the content-addressed store, hash-verified

62
63// If sign is true, transaction must previously have been filled
64TransactionError ExternalSignerScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type, bool sign, bool bip32derivs, int* n_signed, bool finalize) const
65{
66 if (!sign) {
67 return DescriptorScriptPubKeyMan::FillPSBT(psbt, txdata, sighash_type, false, bip32derivs, n_signed, finalize);
68 }
69
70 // Already complete if every input is now signed
71 bool complete = true;
72 for (const auto& input : psbt.inputs) {
73 // TODO: for multisig wallets, we should only care if all _our_ inputs are signed
74 complete &= PSBTInputSigned(input);
75 }
76 if (complete) return TransactionError::OK;
77
78 std::string strFailReason;
79 if(!GetExternalSigner().SignTransaction(psbt, strFailReason)) {
80 tfm::format(std::cerr, "Failed to sign: %s\n", strFailReason);
81 return TransactionError::EXTERNAL_SIGNER_FAILED;
82 }
83 if (finalize) FinalizePSBT(psbt); // This won't work in a multisig setup
84 return TransactionError::OK;
85}
86} // namespace wallet

Callers

nothing calls this directly

Calls 4

PSBTInputSignedFunction · 0.85
FinalizePSBTFunction · 0.85
formatFunction · 0.50
SignTransactionMethod · 0.45

Tested by

no test coverage detected