aboutsummaryrefslogtreecommitdiff
path: root/contrib/signet
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-08-06 22:33:48 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-08-07 20:50:14 +0200
commit0eca5ebaced264d041de815316eaca8cf6fef92f (patch)
tree565f62023c639fa2d349235dbbae74a02957e23f /contrib/signet
parentb0c8246cac97b7792a50afc22ef1fe39c5028e00 (diff)
contrib: refactor: introduce bitcoin-cli RPC call helper in getcoins.py
Diffstat (limited to 'contrib/signet')
-rwxr-xr-xcontrib/signet/getcoins.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/contrib/signet/getcoins.py b/contrib/signet/getcoins.py
index c50c2cc16a..d0a12beb29 100755
--- a/contrib/signet/getcoins.py
+++ b/contrib/signet/getcoins.py
@@ -23,24 +23,26 @@ args = parser.parse_args()
if args.bitcoin_cli_args == []:
args.bitcoin_cli_args = ['-signet']
-if args.faucet.lower() == DEFAULT_GLOBAL_FAUCET:
- # Get the hash of the block at height 1 of the currently active signet chain
+
+def bitcoin_cli(rpc_command_and_params):
+ argv = [args.cmd] + args.bitcoin_cli_args + rpc_command_and_params
try:
- curr_signet_hash = subprocess.check_output([args.cmd] + args.bitcoin_cli_args + ['getblockhash', '1']).strip().decode()
+ return subprocess.check_output(argv).strip().decode()
except FileNotFoundError:
print('The binary', args.cmd, 'could not be found.')
exit()
+
+
+if args.faucet.lower() == DEFAULT_GLOBAL_FAUCET:
+ # Get the hash of the block at height 1 of the currently active signet chain
+ curr_signet_hash = bitcoin_cli(['getblockhash', '1'])
if curr_signet_hash != GLOBAL_FIRST_BLOCK_HASH:
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')
exit()
if args.addr == '':
# get address for receiving coins
- try:
- args.addr = subprocess.check_output([args.cmd] + args.bitcoin_cli_args + ['getnewaddress', 'faucet', 'bech32']).strip()
- except FileNotFoundError:
- print('The binary', args.cmd, 'could not be found.')
- exit()
+ args.addr = bitcoin_cli(['getnewaddress', 'faucet', 'bech32'])
data = {'address': args.addr, 'password': args.password}
try: