diff --git a/src/common/messages.cpp b/src/common/messages.cpp index 5fe3e9e4d86..fc0b4a8861f 100644 --- a/src/common/messages.cpp +++ b/src/common/messages.cpp @@ -116,6 +116,10 @@ bilingual_str PSBTErrorString(PSBTError err) return Untranslated("External signer failed to sign"); case PSBTError::UNSUPPORTED: return Untranslated("Signer does not support PSBT"); + case PSBTError::INCOMPLETE: + return Untranslated("Input needs additional signatures or other data"); + case PSBTError::OK: + return Untranslated("No errors"); // no default case, so the compiler can warn about missing cases } assert(false); diff --git a/src/common/types.h b/src/common/types.h index 0d9cb67ce94..fb9ee4bf31b 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -20,6 +20,8 @@ enum class PSBTError { EXTERNAL_SIGNER_NOT_FOUND, EXTERNAL_SIGNER_FAILED, UNSUPPORTED, + INCOMPLETE, + OK, }; } // namespace common diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 87f8c35a14c..7ea1a9014ae 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -207,7 +207,7 @@ public: int& num_blocks) = 0; //! Fill PSBT. - virtual std::optional fillPSBT(int sighash_type, + virtual std::optional fillPSBT(std::optional sighash_type, bool sign, bool bip32derivs, size_t* n_signed, diff --git a/src/node/psbt.cpp b/src/node/psbt.cpp index 51e252bffca..3933202e0c8 100644 --- a/src/node/psbt.cpp +++ b/src/node/psbt.cpp @@ -64,7 +64,7 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx) // Figure out what is missing SignatureData outdata; - bool complete = SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, 1, &outdata); + bool complete = SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, std::nullopt, &outdata) == PSBTError::OK; // Things are missing if (!complete) { @@ -124,7 +124,7 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx) PSBTInput& input = psbtx.inputs[i]; Coin newcoin; - if (!SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, nullptr, 1) || !psbtx.GetInputUTXO(newcoin.out, i)) { + if (SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, nullptr, std::nullopt) != PSBTError::OK || !psbtx.GetInputUTXO(newcoin.out, i)) { success = false; break; } else { diff --git a/src/psbt.cpp b/src/psbt.cpp index 19d855e4c78..6a1f578fec2 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -4,12 +4,15 @@ #include +#include #include #include #include