2024-02-16 18:03:19 -05:00
|
|
|
#!/bin/sh
|
|
|
|
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
|
|
|
##
|
|
|
|
## SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
conf="${HOME}/.bitcoin/conf.d/cookie.conf"
|
|
|
|
|
|
|
|
if ! systemctl is-active bitcoind >/dev/null 2>&1; then
|
2024-08-06 12:15:24 -04:00
|
|
|
printf '%s\n' "systemd service 'bitcoind' is inactive" >&2
|
|
|
|
printf '%s\n' "remote RPC can't add crendetials" >&2
|
2024-02-16 18:03:19 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rpc_list="$(bitcoin-cli help | awk '/^[a-z]/{print $1}' | tr "\n" ",")"
|
|
|
|
|
2024-08-06 12:15:24 -04:00
|
|
|
printf '%s\n' "rpcwhitelist=__cookie__:${rpc_list}" | \
|
|
|
|
tee -- "${conf}" >/dev/null
|