Add bool PSBTInputSigned

Refactor out a "PSBTInputSigned" function to check if a PSBT is signed,
for use in subsequent commits.

Also improve a related comment.

GitHub-Pull: #14588
Rebased-From: 53e6fffb8f
This commit is contained in:
Glenn Willen 2018-10-26 15:28:48 -07:00 committed by Anthony Fieroni
parent cca21e18ea
commit eaadea01f3
3 changed files with 10 additions and 0 deletions

View file

@ -1309,6 +1309,9 @@ UniValue finalizepsbt(const JSONRPCRequest& request)
} }
bool extract = request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool()); bool extract = request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool());
// signature, but have not combined them yet (e.g. because the combiner that created this
// PartiallySignedTransaction did not understand them), this will combine them into a final
// script.
CMutableTransaction mtx; CMutableTransaction mtx;
bool complete = FinalizeAndExtractPSBT(psbtx, mtx); bool complete = FinalizeAndExtractPSBT(psbtx, mtx);

View file

@ -245,6 +245,10 @@ bool ProduceSignature(const SigningProvider& provider, const BaseSignatureCreato
} }
namespace { namespace {
{
return !input.final_script_sig.empty() || !input.final_script_witness.IsNull();
}
class SignatureExtractorChecker final : public BaseSignatureChecker class SignatureExtractorChecker final : public BaseSignatureChecker
{ {
private: private:

View file

@ -156,6 +156,9 @@ bool ProduceSignature(const SigningProvider& provider, const BaseSignatureCreato
bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType); bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType);
bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType); bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType);
/** Checks whether a PSBTInput is already signed. */
bool PSBTInputSigned(PSBTInput& input);
/** Extract signature data from a transaction input, and insert it. */ /** Extract signature data from a transaction input, and insert it. */
SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nIn, const CTxOut& txout); SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nIn, const CTxOut& txout);
void UpdateInput(CTxIn& input, const SignatureData& data); void UpdateInput(CTxIn& input, const SignatureData& data);