text: //
  //  NSData+Bitcoin.h
  //  WebSocketClient
  //
  //  Created by tongmuxu on 2018/6/30.
  //  Copyright © 2018年 tongmuxu. All rights reserved.
  //
  
  #import <Foundation/Foundation.h>
  
  #define VAR_INT16_HEADER 0xfd
  #define VAR_INT32_HEADER 0xfe
  #define VAR_INT64_HEADER 0xff
  
  // bitcoin script opcodes: https://en.bitcoin.it/wiki/Script#Constants
  #define OP_PUSHDATA1   0x4c
  #define OP_PUSHDATA2   0x4d
  #define OP_PUSHDATA4   0x4e
  #define OP_DUP         0x76
  #define OP_EQUAL       0x87
  #define OP_EQUALVERIFY 0x88
  #define OP_HASH160     0xa9
  #define OP_CHECKSIG    0xac
  
  @interface NSData (Bitcoin)
  
  - (uint8_t)UInt8AtOffset:(NSUInteger)offset;
  - (uint16_t)UInt16AtOffset:(NSUInteger)offset;
  - (uint32_t)UInt32AtOffset:(NSUInteger)offset;
  - (uint64_t)UInt64AtOffset:(NSUInteger)offset;
  - (uint64_t)varIntAtOffset:(NSUInteger)offset length:(NSUInteger *)length;
  - (NSData *)hashAtOffset:(NSUInteger)offset;
  - (NSString *)stringAtOffset:(NSUInteger)offset length:(NSUInteger *)length;
  - (NSData *)dataAtOffset:(NSUInteger)offset length:(NSUInteger *)length;
  - (NSArray *)scriptElements; // an array of NSNumber and NSData objects representing each script element
  - (int)intValue; // returns the opcode used to store the receiver in a script (i.e. OP_PUSHDATA1)
  
  
  @end
  