|
23 | 23 | if args.bitcoin_cli_args == []:
|
24 | 24 | args.bitcoin_cli_args = ['-signet']
|
25 | 25 |
|
26 |
| -if args.faucet.lower() == DEFAULT_GLOBAL_FAUCET: |
27 |
| - # Get the hash of the block at height 1 of the currently active signet chain |
| 26 | + |
| 27 | +def bitcoin_cli(rpc_command_and_params): |
| 28 | + argv = [args.cmd] + args.bitcoin_cli_args + rpc_command_and_params |
28 | 29 | try:
|
29 |
| - curr_signet_hash = subprocess.check_output([args.cmd] + args.bitcoin_cli_args + ['getblockhash', '1']).strip().decode() |
| 30 | + return subprocess.check_output(argv).strip().decode() |
30 | 31 | except FileNotFoundError:
|
31 | 32 | print('The binary', args.cmd, 'could not be found.')
|
32 | 33 | exit()
|
| 34 | + |
| 35 | + |
| 36 | +if args.faucet.lower() == DEFAULT_GLOBAL_FAUCET: |
| 37 | + # Get the hash of the block at height 1 of the currently active signet chain |
| 38 | + curr_signet_hash = bitcoin_cli(['getblockhash', '1']) |
33 | 39 | if curr_signet_hash != GLOBAL_FIRST_BLOCK_HASH:
|
34 | 40 | print('The global faucet cannot be used with a custom Signet network. Please use the global signet or setup your custom faucet to use this functionality.\n')
|
35 | 41 | exit()
|
36 | 42 |
|
37 | 43 | if args.addr == '':
|
38 | 44 | # get address for receiving coins
|
39 |
| - try: |
40 |
| - args.addr = subprocess.check_output([args.cmd] + args.bitcoin_cli_args + ['getnewaddress', 'faucet', 'bech32']).strip() |
41 |
| - except FileNotFoundError: |
42 |
| - print('The binary', args.cmd, 'could not be found.') |
43 |
| - exit() |
| 45 | + args.addr = bitcoin_cli(['getnewaddress', 'faucet', 'bech32']) |
44 | 46 |
|
45 | 47 | data = {'address': args.addr, 'password': args.password}
|
46 | 48 | try:
|
|
0 commit comments