File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 77#include < node/psbt.h>
88#include < policy/policy.h>
99#include < policy/settings.h>
10+ #include < tinyformat.h>
1011
1112#include < numeric>
1213
@@ -39,6 +40,11 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
3940 calc_fee = false ;
4041 }
4142
43+ if (!utxo.IsNull () && utxo.scriptPubKey .IsUnspendable ()) {
44+ result.SetInvalid (strprintf (" PSBT is not valid. Input %u spends unspendable output" , i));
45+ return result;
46+ }
47+
4248 // Check if it is final
4349 if (!utxo.IsNull () && !PSBTInputSigned (input)) {
4450 input_analysis.is_final = false ;
Original file line number Diff line number Diff line change @@ -416,5 +416,10 @@ def test_psbt_input_keys(psbt_input, keys):
416416 analyzed = self .nodes [0 ].analyzepsbt (signed )
417417 assert analyzed ['inputs' ][0 ]['has_utxo' ] and analyzed ['inputs' ][0 ]['is_final' ] and analyzed ['next' ] == 'extractor'
418418
419+ self .log .info ("PSBT spending unspendable outputs should have error message and Creator as next" )
420+ analysis = self .nodes [0 ].analyzepsbt ('cHNidP8BAJoCAAAAAljoeiG1ba8MI76OcHBFbDNvfLqlyHV5JPVFiHuyq911AAAAAAD/////g40EJ9DsZQpoqka7CwmK6kQiwHGyyng1Kgd5WdB86h0BAAAAAP////8CcKrwCAAAAAAWAEHYXCtx0AYLCcmIauuBXlCZHdoSTQDh9QUAAAAAFv8/wADXYP/7//////8JxOh0LR2HAI8AAAAAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHEAABAACAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHENkMak8AAAAA' )
421+ assert_equal (analysis ['next' ], 'creator' )
422+ assert_equal (analysis ['error' ], 'PSBT is not valid. Input 0 spends unspendable output' )
423+
419424if __name__ == '__main__' :
420425 PSBTTest ().main ()
You can’t perform that action at this time.
0 commit comments