✨ Add isStandardOpReturnScript, retrieveOpReturnData to Script
This commit is contained in:
parent
4470cd68d6
commit
04cc92bbcf
|
@ -30,6 +30,6 @@ type_name:
|
|||
excluded:
|
||||
type_body_length: 500
|
||||
line_length: 300
|
||||
file_length: 500
|
||||
file_length: 1000
|
||||
number_separator:
|
||||
minimum_length: 5
|
||||
|
|
|
@ -254,6 +254,21 @@ public class Script {
|
|||
return requirements.nSigRequired > 0
|
||||
}
|
||||
|
||||
public var isStandardOpReturnScript: Bool {
|
||||
guard chunks.count == 2 else {
|
||||
return false
|
||||
}
|
||||
return opcode(at: 0) == .OP_RETURN
|
||||
&& pushedData(at: 1) != nil
|
||||
}
|
||||
|
||||
public var retrieveOpReturnData: Data? {
|
||||
guard isStandardOpReturnScript else {
|
||||
return nil
|
||||
}
|
||||
return pushedData(at: 1)
|
||||
}
|
||||
|
||||
// If typical multisig tx is detected, sets requirements:
|
||||
private func detectMultisigScript() {
|
||||
// multisig script must have at least 4 ops ("OP_1 <pubkey> OP_1 OP_CHECKMULTISIG")
|
||||
|
|
Loading…
Reference in New Issue