mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
improve detection of nested scripts
This commit is contained in:
parent
75730f00ac
commit
c63b492326
1 changed files with 12 additions and 9 deletions
|
@ -145,7 +145,8 @@ public class ScriptChunk {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isScript() {
|
public boolean isScript() {
|
||||||
if(data == null || data.length == 0) {
|
//Do not attempt to parse long data byte arrays into scripts
|
||||||
|
if(data == null || data.length == 0 || data.length > 1000) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,18 +154,20 @@ public class ScriptChunk {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Script script = new Script(data, false);
|
||||||
try {
|
try {
|
||||||
Script script = new Script(data);
|
script.parse();
|
||||||
//Flaky: Test if contains a non-zero opcode, otherwise not a script
|
} catch (ProtocolException e) {
|
||||||
for(ScriptChunk chunk : script.getChunks()) {
|
|
||||||
if(chunk.getOpcode() != OP_0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(ProtocolException e) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Flaky: Test if contains a non-zero opcode, otherwise not a script
|
||||||
|
for(ScriptChunk chunk : script.getChunks()) {
|
||||||
|
if(chunk.getOpcode() != OP_0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue