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 7
7
#include < node/psbt.h>
8
8
#include < policy/policy.h>
9
9
#include < policy/settings.h>
10
+ #include < tinyformat.h>
10
11
11
12
#include < numeric>
12
13
@@ -39,6 +40,11 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
39
40
calc_fee = false ;
40
41
}
41
42
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
+
42
48
// Check if it is final
43
49
if (!utxo.IsNull () && !PSBTInputSigned (input)) {
44
50
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):
416
416
analyzed = self .nodes [0 ].analyzepsbt (signed )
417
417
assert analyzed ['inputs' ][0 ]['has_utxo' ] and analyzed ['inputs' ][0 ]['is_final' ] and analyzed ['next' ] == 'extractor'
418
418
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
+
419
424
if __name__ == '__main__' :
420
425
PSBTTest ().main ()
You can’t perform that action at this time.
0 commit comments