Skip to content
Permalink
Browse files

Add isStandardOpReturnScript, retrieveOpReturnData to Script

  • Loading branch information...
usatie committed Oct 5, 2018
1 parent 4470cd6 commit 04cc92bbcf2958fede6c0b0944af087eb6439abc
Showing with 16 additions and 1 deletion.
  1. +1 −1 .swiftlint.yml
  2. +15 −0 Sources/BitcoinKit/Scripts/Script.swift
@@ -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")

0 comments on commit 04cc92b

Please sign in to comment.
You can’t perform that action at this time.