-
Notifications
You must be signed in to change notification settings - Fork 14
/
schema.coffee
149 lines (132 loc) · 3.43 KB
/
schema.coffee
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
module.exports =
type: "array"
items: {$ref: "#transaction"}
minItems: 1
definitions:
base58:
id: "#base58"
# https://en.bitcoin.it/wiki/Base58Check_encoding
type: "string"
pattern: "^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$"
hex:
id: "#hex"
type: "string"
pattern: "^[0123456789A-Fa-f]+$"
tx_id:
id: "#tx_id"
allOf: [
{$ref: "#hex"}
{
minLength: 64
maxLength: 64
}
]
address:
id: "#address"
allOf: [
{$ref: "#base58"}
{
minLength: 34
maxLength: 34
}
]
signature:
id: "#signature"
allOf: [
{$ref: "#hex"}
{
minLength: 128
maxLength: 128
}
]
transaction:
id: "#transaction"
additionalProperties: false
required: ["metadata", "hash", "inputs", "outputs"]
properties:
metadata:
type: "object"
required: ["amount", "fee"]
properties:
amount:
type: "integer"
fee:
type: "integer"
multipleOf: 10000
status:
type: "string"
enum: ["unsigned", "unconfirmed", "confirmed", "invalid"]
confirmations:
type: "integer"
minimum: 0
block_time:
type: "integer"
version: {type: "integer"}
lock_time: {type: "integer"}
hash: {$ref: "#tx_id"}
inputs:
type: "array"
items: {$ref: "#input"}
minItems: 1
outputs:
type: "array"
items: {$ref: "#output"}
minItems: 1
input:
id: "#input"
type: "object"
additionalProperties: false
required: ["index", "output", "script_sig"]
properties:
index:
type: "integer"
minimum: 0
output: {$ref: "#output"}
sig_hash: {$ref: "#hex"}
script_sig: {$ref: "#hex"}
signatures:
type: "object"
description: "A dictionary of signatures. Keys represent keypair names"
minProperties: 1
maxProperties: 3
additionalProperties: {$ref: "#signature"}
output:
id: "#output"
type: "object"
additionalProperties: false
required: ["hash", "index", "value", "script"]
properties:
hash: {$ref: "#tx_id"}
index:
type: "integer"
minimum: 0
value:
type: "integer"
script:
type: "object"
properties:
type:
type: "string"
enum: ["standard", "p2sh"]
asm:
type: "string"
address: {$ref: "#address"}
metadata:
type: "object"
dependencies:
# if a wallet path is given, the metadata must also contain the
# HDW public seed values. Use case would be for verifying that
# a change output is going to a legit address.
wallet_path: ["public_seeds"]
properties:
wallet_path:
type: "string"
public_seeds:
type: "object"
minProperties: 1
maxProperties: 3
additionalProperties:
anyOf: [
{$ref: "#base58"}
{$ref: "#hex"}
]