Skip to content

Commit

Permalink
Merge #1096: Fix RPC timelockaddress call.
Browse files Browse the repository at this point in the history
66d7e46 Fix RPC timelockaddress call. (Adam Gibson)
  • Loading branch information
AdamISZ committed Dec 7, 2021
2 parents f7e9c16 + 66d7e46 commit ecd1083
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
14 changes: 7 additions & 7 deletions jmclient/jmclient/wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,20 +694,20 @@ def getaddress(self, request, walletname, mixdepth):
return make_jmwalletd_response(request, address=address)

@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)
if not self.wallet_service:
raise NoWalletFound()
if not self.wallet_name == walletname:
raise InvalidRequestFormat()
try:
timelockaddress = wallet_gettimelockaddress(self.wallet_service,
lockdate)
except Exception as e:
return InvalidRequestFormat()
timelockaddress = wallet_gettimelockaddress(
self.wallet_service.wallet, lockdate)
except Exception:
raise InvalidRequestFormat()
if timelockaddress == "":
return InvalidRequestFormat()
return make_jmwalletd_response(request, address=address)
raise InvalidRequestFormat()
return make_jmwalletd_response(request, address=timelockaddress)

@app.route('/wallet/<string:walletname>/configget', methods=["POST"])
def configget(self, request, walletname):
Expand Down
18 changes: 15 additions & 3 deletions jmclient/test/test_wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from jmbase import get_nontor_agent, hextobin, BytesProducer, get_log
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)
from jmclient.wallet_rpc import api_version_string
from commontest import make_wallets
Expand Down Expand Up @@ -71,7 +71,7 @@ def setUp(self):
# the sync for test, by some means or other.
self.daemon.wallet_service = make_wallets_to_list(make_wallets(
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()
sync_wallets([self.daemon.wallet_service])
# dummy tx example to force a notification event:
Expand Down Expand Up @@ -173,7 +173,7 @@ def test_create_list_lock_unlock(self):
addr = root + "/wallet/create"
addr = addr.encode()
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,
self.process_create_wallet_response)

Expand Down Expand Up @@ -266,6 +266,18 @@ def test_getaddress(self):
yield self.do_request(agent, b"GET", addr, None,
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):
json_body = json.loads(response.decode("utf-8"))
assert validate_address(json_body["address"])[0]
Expand Down

0 comments on commit ecd1083

Please sign in to comment.