Simon Volpert gmipay / 1e28aad
Add handling of the 'xpub' configuration key Since it is supposed to be provided by the user, it explicitly has no default value Also improved configuration error messages and ordered those by importance Simon Volpert 3 years ago
1 changed file(s) with 12 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
+12
-3
get less more
2525
2626 # Configuration defaults
2727 file_path = ''
28 xpub = ''
2829 default_price = 1000.0
2930 api_url = 'https://api.blockchair.com/bitcoin-cash/dashboards/address/{address}'
3031 api_key_balance = 'data.{address}.address.balance'
3738 # location should be in a place inaccessible from your capsule (outside the
3839 # document root):
3940 path={file_path}
41 # Set this to the extended public key (xPub) of your receiving wallet, which
42 # will be used to generate a fresh receiving address for every payment.
43 xpub=
4044 # Set this to the default price any given file should be in BITs (1,000,000th
4145 # of a Bitcoin Cash):
4246 default_price={default_price}
158162 for line in _data:
159163 if line.startswith('path='):
160164 file_path = line[5:]
165 elif line.startswith('xpub='):
166 xpub = line[5:]
161167 elif line.startswith('default_price='):
162168 default_price = round(float(line[14:]), 2)
163169 elif line.startswith('api_url='):
170176 api_unit = line[9:]
171177
172178 # Check configuration validity
179 if file_path == '':
180 print('42 Missing required configuration value: path\r')
181 raise SystemExit
182 if xpub == '':
183 print('42 Missing required configuration value: xpub\r')
184 raise SystemExit
173185 if api_unit not in ['native', 'satoshi']:
174186 print(f'42 Bad configuration value for api_unit: {api_unit}\r')
175187 raise SystemExit
176188 # Check if the file exists
177 if file_path == '':
178 print('51 Not found\r')
179 raise SystemExit
180189 request_file = Path(file_path) / path_info
181190 if not request_file.is_file():
182191 print('51 Not found\r')