Skip to content

Commit e8af849

Browse files
author
Jamie C. Driver
committed
descriptor: allow x-only pubkeys and add test case for a tr() descriptor
1 parent 0406e89 commit e8af849

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

main/descriptor.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ static const uint8_t CURRENT_DESCRIPTOR_RECORD_VERSION = 0;
2424
#define MIN_DESCRIPTOR_BYTES_LEN (2 + 2 + 4 + 1 + 0 + 0)
2525

2626
// Stack size required for miniscript parsing.
27-
// Allow 1k, plus 1k per 'depth' level, plus 4k for handling the
27+
// Allow 2k, plus 1k per 'depth' level, plus 4k for handling the
2828
// public keys which are expected to be at the end of most branches.
29-
#define DESCRIPTOR_PARSE_STACK_SIZE(depth) ((depth + 5) * 1024)
29+
#define DESCRIPTOR_PARSE_STACK_SIZE(depth) ((depth + 6) * 1024)
3030

3131
// We reject generating addresses from descriptors more than a certain depth, as this process
3232
// is recursive and so can use unbounded amounts of stack. This protects us against a badly-
@@ -251,11 +251,7 @@ static bool parse_descriptor(const char* name, const descriptor_data_t* descript
251251
*errmsg = "Descriptors with private keys are not supported";
252252
goto fail;
253253
}
254-
if (features & WALLY_MS_IS_X_ONLY) {
255-
JADE_LOGE("Descriptor '%s' appears to contain x-only keys (taproot?)", name);
256-
*errmsg = "Descriptors with x-only keys are not supported";
257-
goto fail;
258-
}
254+
259255
if (!(features & WALLY_MS_IS_RANGED)) {
260256
JADE_LOGE("Descriptor '%s' appears not to contain any wildcards", name);
261257
*errmsg = "Descriptors without any wildcards are not supported";
@@ -329,9 +325,7 @@ bool descriptor_get_signers(const char* name, const descriptor_data_t* descripto
329325
*errmsg = "Failed to get key features";
330326
goto cleanup;
331327
}
332-
if ((key_features
333-
& (WALLY_MS_IS_PRIVATE | WALLY_MS_IS_UNCOMPRESSED | WALLY_MS_IS_RAW | WALLY_MS_IS_X_ONLY
334-
| WALLY_MS_IS_PARENTED))
328+
if ((key_features & (WALLY_MS_IS_PRIVATE | WALLY_MS_IS_UNCOMPRESSED | WALLY_MS_IS_RAW | WALLY_MS_IS_PARENTED))
335329
!= WALLY_MS_IS_PARENTED) {
336330
*errmsg = "Invalid key features";
337331
goto cleanup;

test_data/descriptor_tr.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"input": {
3+
"network": "localtest",
4+
"descriptor_name": "test_descriptor",
5+
"descriptor": "tr(@0/<0;1>/*)",
6+
"datavalues": {
7+
"@0": "[e3ebcc79/86'/1'/0']tpubDCXH5giLNcN6MfDQwvskJVJMT4HemX3LKmKFac5xe9rzaFVkiUbx8wrPAt9NGKW2yXS8XsnqYm6FSP36WD4fnhNr5CweqaRwZcknepxtc9d"
8+
}
9+
},
10+
"address_tests": [
11+
{
12+
"branch": 0,
13+
"pointer": 0,
14+
"expected_address": "bcrt1pem42zy9qwlr9vynrtg0m5gqvz99txm5slx4dmkyfe6uhyskzz8qshv7x9n"
15+
},
16+
{
17+
"branch": 0,
18+
"pointer": 1,
19+
"expected_address": "bcrt1psu9scqlwhpjv7nv0ecslpda3uwrghf7h03edux4wzyefsvtpasfsjhkkkd"
20+
}
21+
]
22+
}

test_jade.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ def _get_test_cases(pattern):
540540
MULTI_REG_SS_TESTS = "multisig_reg_ss_*.json"
541541
MULTI_REG_FILE_TESTS = "multisig_file_*.json"
542542
MULTI_REG_BAD_FILE_TESTS = "multisig_bad_file_*.json"
543+
DESCRIPTOR_REG_TESTS = "descriptor_*.json"
543544
DESCRIPTOR_REG_SS_TESTS = "descriptor_ss_*.json"
544545
SIGN_MSG_TESTS = "msg_*.json"
545546
SIGN_MSG_FILE_TESTS = "msgfile_*.json"
@@ -3341,8 +3342,8 @@ def test_generic_multisig_ss_signer(jadeapi):
33413342
_check_multisig_registration(jadeapi, multisig_data)
33423343

33433344

3344-
def test_miniscript_descriptor_registration(jadeapi):
3345-
for descriptor_data in _get_test_cases(DESCRIPTOR_REG_SS_TESTS):
3345+
def test_miniscript_descriptor_registration(jadeapi, pattern):
3346+
for descriptor_data in _get_test_cases(pattern):
33463347
# Register the descriptor
33473348
inputdata = descriptor_data['input']
33483349
rslt = jadeapi.register_descriptor(inputdata['network'],
@@ -3398,10 +3399,6 @@ def test_miniscript_descriptor_registration(jadeapi):
33983399
assert rslt == addr_test['expected_address']
33993400

34003401

3401-
def test_miniscript_descriptor_registration_ss_signer(jadeapi):
3402-
test_miniscript_descriptor_registration(jadeapi) # for now ...
3403-
3404-
34053402
def test_12word_mnemonic(jadeapi):
34063403
# Short sanity-test of 12-word mnemonic
34073404
rslt = jadeapi.set_mnemonic(TEST_MNEMONIC_12)
@@ -3674,7 +3671,7 @@ def run_api_tests(jadeapi, isble, qemu, authuser=False):
36743671
test_generic_multisig_files(jadeapi)
36753672

36763673
# Test descriptor wallets
3677-
test_miniscript_descriptor_registration(jadeapi)
3674+
test_miniscript_descriptor_registration(jadeapi, DESCRIPTOR_REG_TESTS)
36783675

36793676
# Get (receive) green-addresses, get-xpub, and sign-message
36803677
test_get_greenaddress_receive_address(jadeapi)
@@ -3708,9 +3705,7 @@ def run_api_tests(jadeapi, isble, qemu, authuser=False):
37083705
test_generic_multisig_ss_signer(jadeapi)
37093706

37103707
# Test the descriptor wallets again, using a second signer
3711-
# NOTE: some of these tests assume 'test_miniscript_descriptor_registration()' test
3712-
# has already been run, to register the descriptors for the test mnemonic signer
3713-
test_miniscript_descriptor_registration_ss_signer(jadeapi)
3708+
test_miniscript_descriptor_registration(jadeapi, DESCRIPTOR_REG_SS_TESTS)
37143709

37153710
test_get_singlesig_receive_address(jadeapi)
37163711
test_sign_liquid_tx(jadeapi, has_psram, has_ble, SIGN_LIQUID_TXN_SINGLE_SIG_TESTS)

0 commit comments

Comments
 (0)