terrors_libbitcoin.py - obelisk - Electrum server using libbitcoin as its backend
HTML git clone https://git.parazyd.org/obelisk
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
terrors_libbitcoin.py (3737B)
---
1 #!/usr/bin/env python3
2 # Copyright (C) 2021 Ivan J. <parazyd@dyne.org>
3 #
4 # This file is part of obelisk
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License version 3
8 # as published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
14 #
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 """Enumerated error codes that can be returned by libbitcoin"""
18 from enum import Enum
19
20
21 def make_error_code(ec):
22 """Return ErrorCode from ec"""
23 if not ec:
24 return None
25 return ZMQError(ec) # pragma: no cover
26
27
28 class ZMQError(Enum):
29 """libbitcoin error codes"""
30
31 # general codes
32 success = 0
33 deprecated1 = 6
34 unknown = 43
35 not_found = 3
36 file_system = 42
37 not_implemented = 4
38 oversubscribed = 71
39
40 # network
41 service_stopped = 1
42 operation_failed = 2
43 resolve_failed = 7
44 network_unreachable = 8
45 address_in_use = 9
46 listen_failed = 10
47 accept_failed = 11
48 bad_stream = 12
49 channel_timeout = 13
50 address_blocked = 44
51 channel_stopped = 45
52 peer_throttling = 73
53
54 # database
55 store_block_duplicate = 66
56 store_block_invalid_height = 67
57 store_block_missing_parent = 68
58 store_lock_failure = 85
59 store_incorrect_state = 86
60
61 # blockchain
62 duplicate_block = 51
63 orphan_block = 5
64 invalid_previous_block = 24
65 insufficient_work = 48
66 duplicate_transaction = 84
67 orphan_transaction = 14
68 transaction_version = 17
69 insufficient_fee = 70
70 stale_chain = 75
71 dusty_transaction = 76
72
73 # check header
74 invalid_proof_of_work = 26
75 futuristic_timestamp = 27
76
77 # accept header
78 checkpoints_failed = 35
79 invalid_block_version = 36
80 incorrect_proof_of_work = 32
81 timestamp_too_early = 33
82
83 # check block
84 block_size_limit = 50
85 empty_block = 47
86 first_not_coinbase = 28
87 extra_coinbases = 29
88 internal_duplicate = 49
89 block_internal_double_spend = 15
90 forward_reference = 79
91 merkle_mismatch = 31
92 block_legacy_sigop_limit = 30
93
94 # accept block
95 block_non_final = 34
96 coinbase_height_mismatch = 37
97 coinbase_value_limit = 41
98 block_embedded_sigop_limit = 52
99 invalid_witness_commitment = 25
100 block_weight_limit = 82
101
102 # check transaction
103 empty_transaction = 20
104 previous_output_null = 23
105 spend_overflow = 21
106 invalid_coinbase_script_size = 22
107 coinbase_transaction = 16
108 transaction_internal_double_spend = 72
109 transaction_size_limit = 53
110 transaction_legacy_sigop_limit = 54
111
112 # accept transaction
113 transaction_non_final = 74
114 premature_validation = 69
115 unspent_duplicate = 38
116 missing_previous_output = 19
117 double_spend = 18
118 coinbase_maturity = 46
119 spend_exceeds_value = 40
120 transaction_embedded_sigop_limit = 55
121 sequence_locked = 78
122 transaction_weight_limit = 83
123
124 # connect input
125 invalid_script = 39
126 invalid_script_size = 56
127 invalid_push_data_size = 57
128 invalid_operation_count = 58
129 invalid_stack_size = 59
130 invalid_stack_scope = 60
131 invalid_script_embed = 61
132 invalid_signature_encoding = 62
133 deprecated2 = 63
134 incorrect_signature = 64
135 unexpected_witness = 77
136 invalid_witness = 80
137 dirty_witness = 81
138 stack_false = 65
139
140 # http
141 http_invalid_request = 90
142 http_method_not_found = 91
143 http_internal_error = 92