Browse Source

Merge #1096: Fix RPC timelockaddress call.

66d7e46 Fix RPC timelockaddress call. (Adam Gibson)
master
Adam Gibson 4 years ago
parent
commit
ecd1083cae
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 14
      jmclient/jmclient/wallet_rpc.py
  2. 18
      jmclient/test/test_wallet_rpc.py

14
jmclient/jmclient/wallet_rpc.py

@ -694,20 +694,20 @@ class JMWalletDaemon(Service):
return make_jmwalletd_response(request, address=address) return make_jmwalletd_response(request, address=address)
@app.route('/wallet/<string:walletname>/address/timelock/new/<string:lockdate>', methods=['GET']) @app.route('/wallet/<string:walletname>/address/timelock/new/<string:lockdate>', methods=['GET'])
def gettimelockaddress(self, request, walletname): def gettimelockaddress(self, request, walletname, lockdate):
self.check_cookie(request) self.check_cookie(request)
if not self.wallet_service: if not self.wallet_service:
raise NoWalletFound() raise NoWalletFound()
if not self.wallet_name == walletname: if not self.wallet_name == walletname:
raise InvalidRequestFormat() raise InvalidRequestFormat()
try: try:
timelockaddress = wallet_gettimelockaddress(self.wallet_service, timelockaddress = wallet_gettimelockaddress(
lockdate) self.wallet_service.wallet, lockdate)
except Exception as e: except Exception:
return InvalidRequestFormat() raise InvalidRequestFormat()
if timelockaddress == "": if timelockaddress == "":
return InvalidRequestFormat() raise InvalidRequestFormat()
return make_jmwalletd_response(request, address=address) return make_jmwalletd_response(request, address=timelockaddress)
@app.route('/wallet/<string:walletname>/configget', methods=["POST"]) @app.route('/wallet/<string:walletname>/configget', methods=["POST"])
def configget(self, request, walletname): def configget(self, request, walletname):

18
jmclient/test/test_wallet_rpc.py

@ -9,7 +9,7 @@ from autobahn.twisted.websocket import WebSocketClientFactory, \
from jmbase import get_nontor_agent, hextobin, BytesProducer, get_log from jmbase import get_nontor_agent, hextobin, BytesProducer, get_log
from jmbitcoin import CTransaction from jmbitcoin import CTransaction
from jmclient import (load_test_config, jm_single, from jmclient import (load_test_config, jm_single, SegwitWalletFidelityBonds,
JMWalletDaemon, validate_address, start_reactor) JMWalletDaemon, validate_address, start_reactor)
from jmclient.wallet_rpc import api_version_string from jmclient.wallet_rpc import api_version_string
from commontest import make_wallets from commontest import make_wallets
@ -71,7 +71,7 @@ class WalletRPCTestBase(object):
# the sync for test, by some means or other. # the sync for test, by some means or other.
self.daemon.wallet_service = make_wallets_to_list(make_wallets( self.daemon.wallet_service = make_wallets_to_list(make_wallets(
1, wallet_structures=[wallet_structures[0]], 1, wallet_structures=[wallet_structures[0]],
mean_amt=self.mean_amt))[0] mean_amt=self.mean_amt, wallet_cls=SegwitWalletFidelityBonds))[0]
jm_single().bc_interface.tickchain() jm_single().bc_interface.tickchain()
sync_wallets([self.daemon.wallet_service]) sync_wallets([self.daemon.wallet_service])
# dummy tx example to force a notification event: # dummy tx example to force a notification event:
@ -173,7 +173,7 @@ class TrialTestWRPC_DisplayWallet(WalletRPCTestBase, unittest.TestCase):
addr = root + "/wallet/create" addr = root + "/wallet/create"
addr = addr.encode() addr = addr.encode()
body = BytesProducer(json.dumps({"walletname": testfileloc, body = BytesProducer(json.dumps({"walletname": testfileloc,
"password": "hunter2", "wallettype": "sw"}).encode()) "password": "hunter2", "wallettype": "sw-fb"}).encode())
yield self.do_request(agent, b"POST", addr, body, yield self.do_request(agent, b"POST", addr, body,
self.process_create_wallet_response) self.process_create_wallet_response)
@ -266,6 +266,18 @@ class TrialTestWRPC_DisplayWallet(WalletRPCTestBase, unittest.TestCase):
yield self.do_request(agent, b"GET", addr, None, yield self.do_request(agent, b"GET", addr, None,
self.process_new_addr_response) self.process_new_addr_response)
@defer.inlineCallbacks
def test_gettimelockaddress(self):
self.daemon.auth_disabled = True
agent = get_nontor_agent()
addr = self.get_route_root()
addr += "/wallet/"
addr += self.daemon.wallet_name
addr += "/address/timelock/new/2023-02"
addr = addr.encode()
yield self.do_request(agent, b"GET", addr, None,
self.process_new_addr_response)
def process_new_addr_response(self, response): def process_new_addr_response(self, response):
json_body = json.loads(response.decode("utf-8")) json_body = json.loads(response.decode("utf-8"))
assert validate_address(json_body["address"])[0] assert validate_address(json_body["address"])[0]

Loading…
Cancel
Save