mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-18 00:45:45 +02:00
Merge #17524: psbt: handle unspendable psbts
773d4572a4
Mark PSBTs spending unspendable outputs as invalid in analysis (Andrew Chow)638e40cb60
Have a PSBTAnalysis state that indicates invalid PSBT (Andrew Chow) Pull request description: When analyzing an unspendable PSBT, report that it is unspendable and exit analysis early. ACKs for top commit: Sjors: ACK773d457
instagibbs: After some thought ACK773d4572a4
Tree-SHA512: 99b0cb2fa1ea37593fc65a20effe881639d69ddeeecf5197bc87bc7f2220cbeb40f1d429d517e4d27f2e9fb563a00cd845d2b4b1ce05246a75a6cb56fb9b0ba5
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <node/psbt.h>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/settings.h>
|
||||
#include <tinyformat.h>
|
||||
|
||||
#include <numeric>
|
||||
|
||||
@ -39,6 +40,11 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
|
||||
calc_fee = false;
|
||||
}
|
||||
|
||||
if (!utxo.IsNull() && utxo.scriptPubKey.IsUnspendable()) {
|
||||
result.SetInvalid(strprintf("PSBT is not valid. Input %u spends unspendable output", i));
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if it is final
|
||||
if (!utxo.IsNull() && !PSBTInputSigned(input)) {
|
||||
input_analysis.is_final = false;
|
||||
|
@ -30,6 +30,17 @@ struct PSBTAnalysis {
|
||||
Optional<CAmount> fee; //!< Amount of fee being paid by the transaction
|
||||
std::vector<PSBTInputAnalysis> inputs; //!< More information about the individual inputs of the transaction
|
||||
PSBTRole next; //!< Which of the BIP 174 roles needs to handle the transaction next
|
||||
std::string error; //!< Error message
|
||||
|
||||
void SetInvalid(std::string err_msg)
|
||||
{
|
||||
estimated_vsize = nullopt;
|
||||
estimated_feerate = nullopt;
|
||||
fee = nullopt;
|
||||
inputs.clear();
|
||||
next = PSBTRole::CREATOR;
|
||||
error = err_msg;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user