package bitcoinml

  1. Overview
  2. Docs

Source file script_scripthash.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
open Script;;
open Address;;

module Input = struct 
  type t = int;;
  let check v = true;;
  let encode v = Script.empty;;
  let decode v = 0;;
end

module Output = struct 
  type t = string;;

  let check s = 
    match fst s with
    | OP_HASH160 :: OP_DATA (20, sh) :: OP_EQUAL :: [] -> true
    | _ -> false
  ;;

  let encode sh = Script.of_opcodes [ OP_HASH160; OP_DATA (20, sh); OP_EQUAL ];;

  let decode s = 
    match fst s with
    | OP_HASH160 :: OP_DATA (20, sh) :: OP_EQUAL :: [] -> sh
    | _ -> ""
  ;;

  let spendable_by s prefix = decode s |> Address.of_pubhash prefix.scripthash;; 
end


(*
module Script_scripthash = Script_template.Make_template
  (Input)
  (Output)  
;;
*)