Skip to content
Permalink
Browse files

Merge pull request #173 from yenom/add-is-opreturn

 Add isStandardOpReturnScript, retrieveOpReturnData to Script
  • Loading branch information...
usatie committed Oct 5, 2018
2 parents 4470cd6 + 0b16ab4 commit adf36d6225d6e7f155222e98368e8a7cfe04b6da
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 func standardOpReturnData() -> 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 adf36d6

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