Page MenuHomePhabricator

add importdescriptors RPC and tests for native descriptor wallets
ClosedPublic

Authored by deadalnix on Nov 19 2020, 23:54.

Details

Summary

Co-authored-by: Andrew Chow <achow101-github@achow101.com>

Backport of Core PR16528 [36/43] : https://github.com/bitcoin/bitcoin/pull/16528/commits/f193ea889ddb53d9a5c47647966681d525e38368

Add the wallet_util changes from 223588b because the patch is broken without it.

Test Plan
ninja all check-all

Event Timeline

deadalnix added inline comments.
test/functional/wallet_importdescriptors.py
284 ↗(On Diff #25898)

This is flaky for some reason.

Failed tests logs:

====== Bitcoin ABC functional tests with the next upgrade activated: wallet_importdescriptors.py ======

------- Stdout: -------
2020-11-20T00:01:39.202000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20201119_235929/wallet_importdescriptors_700
2020-11-20T00:01:39.472000Z TestFramework (INFO): Setting up wallets
2020-11-20T00:01:39.512000Z TestFramework (INFO): Mining coins
2020-11-20T00:01:39.562000Z TestFramework (INFO): Import should fail if a descriptor is not provided
2020-11-20T00:01:39.565000Z TestFramework (INFO): Should import a p2pkh descriptor
2020-11-20T00:01:39.572000Z TestFramework (INFO): Internal addresses cannot have labels
2020-11-20T00:01:39.578000Z TestFramework (INFO): Should import a 1-of-2 bare multisig from descriptor
2020-11-20T00:01:39.583000Z TestFramework (INFO): Should not treat individual keys from the imported bare multisig as watchonly
2020-11-20T00:01:39.583000Z TestFramework (INFO): Ranged descriptors cannot have labels
2020-11-20T00:01:39.584000Z TestFramework (INFO): Private keys required for private keys enabled wallet
2020-11-20T00:01:39.585000Z TestFramework (INFO): Ranged descriptor import should warn without a specified range
2020-11-20T00:01:39.591000Z TestFramework (INFO): Should not import a ranged descriptor that includes xpriv into a watch-only wallet
2020-11-20T00:01:39.598000Z TestFramework (INFO): Key ranges should be imported in order
2020-11-20T00:01:39.643000Z TestFramework (INFO): Check imported descriptors are not active by default
2020-11-20T00:01:39.649000Z TestFramework (INFO): Should import a descriptor with a WIF private key as spendable
2020-11-20T00:01:39.792000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
  File "/work/test/functional/test_framework/authproxy.py", line 117, in _request
    return self._get_response()
  File "/work/test/functional/test_framework/authproxy.py", line 183, in _get_response
    http_response = self.__conn.getresponse()
  File "/usr/lib/python3.7/http/client.py", line 1336, in getresponse
    response.begin()
  File "/usr/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.7/http/client.py", line 275, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 120, in main
    self.run_test()
  File "/work/test/functional/wallet_importdescriptors.py", line 284, in run_test
    signed_tx = wpriv.signrawtransactionwithwallet(tx)
  File "/work/test/functional/test_framework/coverage.py", line 48, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 157, in __call__
    'POST', self.__url.path, postdata.encode('utf-8'))
  File "/work/test/functional/test_framework/authproxy.py", line 122, in _request
    self.__conn.request(method, path, postdata, headers)
  File "/usr/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1290, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1239, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/usr/lib/python3.7/http/client.py", line 938, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/usr/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
2020-11-20T00:01:39.843000Z TestFramework (INFO): Stopping nodes
2020-11-20T00:01:39.844000Z TestFramework.node1 (ERROR): Unable to stop node.
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_node.py", line 374, in stop_node
    self.stop(wait=wait)
  File "/work/test/functional/test_framework/coverage.py", line 48, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 157, in __call__
    'POST', self.__url.path, postdata.encode('utf-8'))
  File "/work/test/functional/test_framework/authproxy.py", line 116, in _request
    self.__conn.request(method, path, postdata, headers)
  File "/usr/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1255, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/lib/python3.7/http/client.py", line 1108, in putrequest
    raise CannotSendRequest(self.__state)
http.client.CannotSendRequest: Request-sent
------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/wallet_importdescriptors.py", line 468, in <module>
    ImportDescriptorsTest().main()
  File "/work/test/functional/test_framework/test_framework.py", line 140, in main
    exit_code = self.shutdown()
  File "/work/test/functional/test_framework/test_framework.py", line 250, in shutdown
    self.stop_nodes()
  File "/work/test/functional/test_framework/test_framework.py", line 475, in stop_nodes
    node.wait_until_stopped()
  File "/work/test/functional/test_framework/test_node.py", line 416, in wait_until_stopped
    wait_until(self.is_node_stopped, timeout=timeout)
  File "/work/test/functional/test_framework/util.py", line 263, in wait_until
    if predicate():
  File "/work/test/functional/test_framework/test_node.py", line 407, in is_node_stopped
    "Node returned non-zero exit code ({}) when stopping".format(return_code))
AssertionError: [node 1] Node returned non-zero exit code (-11) when stopping

Each failure log is accessible here:
Bitcoin ABC functional tests with the next upgrade activated: wallet_importdescriptors.py

majcosta requested changes to this revision.Nov 21 2020, 02:48
majcosta added a subscriber: majcosta.
majcosta added inline comments.
src/wallet/rpcdump.cpp
2127 ↗(On Diff #25920)

my CashAddr wallet*

test/functional/wallet_importdescriptors.py
268 ↗(On Diff #25920)

why the change? the original descriptor is valid. is sh(pkh(_)) not a thing for us?

This revision now requires changes to proceed.Nov 21 2020, 02:48

Update RPC doc
Restore use of 'sh(pkh(...))' in a test case.

This revision is now accepted and ready to land.Nov 21 2020, 15:00