mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-20 07:00:44 +02:00
rpcauth: Support storing credentials in a file
To be used with -rpcauthfile
This commit is contained in:
parent
98965fdadc
commit
6d69a2974b
@ -24,6 +24,7 @@ def main():
|
||||
parser = ArgumentParser(description='Create login credentials for a JSON-RPC user')
|
||||
parser.add_argument('username', help='the username for authentication')
|
||||
parser.add_argument('password', help='leave empty to generate a random password or specify "-" to prompt for password', nargs='?')
|
||||
parser.add_argument('--output', dest='output', help='file to store credentials, to be used with -rpcauthfile')
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.password:
|
||||
@ -35,9 +36,14 @@ def main():
|
||||
salt = generate_salt(16)
|
||||
password_hmac = password_to_hmac(salt, args.password)
|
||||
|
||||
print('String to be appended to bitcoin.conf:')
|
||||
print(f'rpcauth={args.username}:{salt}${password_hmac}')
|
||||
print(f'Your password:\n{args.password}')
|
||||
if args.output:
|
||||
file = open(args.output, "x")
|
||||
file.write(f'{args.username}:{salt}${password_hmac}')
|
||||
print(f'Your password:\n{args.password}')
|
||||
else:
|
||||
print('String to be appended to bitcoin.conf:')
|
||||
print(f'rpcauth={args.username}:{salt}${password_hmac}')
|
||||
print(f'Your password:\n{args.password}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user