2020-12-15 00:44:48 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import configparser
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
import getopt
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
description = "# Setting bitcoinRPC in the joinmarket.cfg"
|
|
|
|
|
print(description)
|
|
|
|
|
|
|
|
|
|
try:
|
2021-03-02 10:22:31 +00:00
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "nrphcw", ["network=","rpc_user=","rpc_pass=","rpc_host=","rpc_port=","rpc_wallet="])
|
2020-12-15 00:44:48 +00:00
|
|
|
except getopt.GetoptError:
|
|
|
|
|
print('# Usage:')
|
2021-03-02 10:22:31 +00:00
|
|
|
print('python /home/joinmarket/set.bitcoinrpc.py --network=$network --rpc_user=$rpc_user --rpc_pass=$rpc_pass --rpc_host=$rpc_host --rpc_port=$rpc_port --rpc_wallet=$rpc_wallet')
|
2020-12-15 00:44:48 +00:00
|
|
|
sys.exit(2)
|
|
|
|
|
|
|
|
|
|
for opt, arg in opts:
|
2021-03-02 10:22:31 +00:00
|
|
|
if opt in ('-n','--network'):
|
2022-03-02 22:09:50 +03:00
|
|
|
network = arg
|
2021-03-02 10:22:31 +00:00
|
|
|
elif opt in ('-r','--rpc_user'):
|
2020-12-15 00:44:48 +00:00
|
|
|
rpc_user = arg
|
|
|
|
|
elif opt in ('-p','--rpc_pass'):
|
|
|
|
|
rpc_password = arg
|
|
|
|
|
elif opt in ('-h','--rpc_host'):
|
|
|
|
|
rpc_host = arg
|
|
|
|
|
elif opt in ('-c','--rpc_port'):
|
|
|
|
|
rpc_port = arg
|
2021-02-14 13:10:38 +00:00
|
|
|
elif opt in ('-w','--rpc_wallet'):
|
2022-03-02 22:09:50 +03:00
|
|
|
rpc_wallet_file = arg
|
2020-12-15 00:44:48 +00:00
|
|
|
else:
|
|
|
|
|
assert False, "unhandled option"
|
2022-03-02 22:09:50 +03:00
|
|
|
|
2020-12-15 00:44:48 +00:00
|
|
|
config = configparser.ConfigParser(strict=False, comment_prefixes='/', allow_no_value=True)
|
|
|
|
|
config.read('/home/joinmarket/.joinmarket/joinmarket.cfg')
|
2022-03-02 22:09:50 +03:00
|
|
|
config.set('BLOCKCHAIN','network',network)
|
2020-12-15 00:44:48 +00:00
|
|
|
config.set('BLOCKCHAIN','rpc_user',rpc_user)
|
|
|
|
|
config.set('BLOCKCHAIN','rpc_password',rpc_password)
|
|
|
|
|
config.set('BLOCKCHAIN','rpc_host',rpc_host)
|
|
|
|
|
config.set('BLOCKCHAIN','rpc_port',rpc_port)
|
2021-02-14 13:10:38 +00:00
|
|
|
config.set('BLOCKCHAIN','rpc_wallet_file',rpc_wallet_file)
|
2020-12-15 00:44:48 +00:00
|
|
|
|
|
|
|
|
with open('/home/joinmarket/.joinmarket/joinmarket.cfg', 'w') as configfile:
|
|
|
|
|
config.write(configfile)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|