diff options
author | Glenn Willen <gwillen@nerdnet.org> | 2018-10-26 15:28:48 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2018-12-03 10:36:08 -0800 |
commit | 39ece4fc2807b3442759d879985146ac0de9742d (patch) | |
tree | d1cf0af99a4d6bdca38f67f0fb7b05b686aff61d /src/script | |
parent | 70ee1f8709a54a9aeac004d8589faa08f665587a (diff) |
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: 53e6fffb8f5b10f94708d33d667a67cb91c2d09d
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/sign.cpp | 8 | ||||
-rw-r--r-- | src/script/sign.h | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 190c0bf687..945e162355 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -233,10 +233,14 @@ bool ProduceSignature(const SigningProvider& provider, const BaseSignatureCreato return sigdata.complete; } +bool PSBTInputSigned(PSBTInput& input) +{ + return !input.final_script_sig.empty() || !input.final_script_witness.IsNull(); +} + bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& tx, PSBTInput& input, SignatureData& sigdata, int index, int sighash) { - // if this input has a final scriptsig or scriptwitness, don't do anything with it - if (!input.final_script_sig.empty() || !input.final_script_witness.IsNull()) { + if (PSBTInputSigned(input)) { return true; } diff --git a/src/script/sign.h b/src/script/sign.h index 79cd6dc53f..ebc742c09d 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -714,6 +714,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 CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType); +/** Checks whether a PSBTInput is already signed. */ +bool PSBTInputSigned(PSBTInput& input); + /** Signs a PSBTInput, verifying that all provided data matches what is being signed. */ bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& tx, PSBTInput& input, SignatureData& sigdata, int index, int sighash = 1); |