-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbtc_wallet_server.py
39 lines (26 loc) · 978 Bytes
/
btc_wallet_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# encoding: utf-8
import json
from flask import Flask
from flask import request
from btc_wallet import dump_private_key_from_wallet_db
from btc_types import Global
app = Flask(__name__)
@app.route('/dumpwallet', methods=['POST'])
def dumpwallet():
req_obj = json.loads(request.data)
wallet_id = str(req_obj["wallet_id"])
if wallet_id in Global.wallet_ids_in_processing:
resp_obj = {}
resp_obj["wallet_id"] = wallet_id
resp_obj["err_msg"] = "wallet id %s is in processing now" % wallet_id
return json.dumps(resp_obj)
wallet_file_dir = req_obj["wallet_file_dir"]
wallet_pass = req_obj["wallet_pass"]
Global.wallet_ids_in_processing.add(wallet_id)
resp_obj = dump_private_key_from_wallet_db(wallet_file_dir, wallet_pass)
Global.wallet_ids_in_processing.remove(wallet_id)
resp_obj["wallet_id"] = wallet_id
return json.dumps(resp_obj)
if __name__ == "__main__":
app.run()