wallet: importdescriptors should output the request on error #35224

Open
kevkevinpal wants to merge 1 commit from importDescriptorsPrintoutRequestOnFailure into master AGit
kevkevinpal commented 2026-05-06 16:33:57 +00:00 (Migrated from github.com)

Motivation

When importdescriptors is given multiple requests, a missing timestamp still fails the whole call with a static error (Missing required timestamp field for key). That does not say which request failed.

#34861 is merged. Other parse failures are returned per item, but a missing or invalid timestamp is still a top-level RPC error from GetImportTimestamp.

Solution

Include the failing request in that error message.

Example

Request

[
  {
    "desc": "wpkh([abcd1234/84h/1h/0h]tpub.../0/*)#x9abc123",
    "timestamp": 1710000000,
    "active": true,
    "range": [0, 100]
  },
  {
    "desc": "pkh(039dcc64c5c644baf0145a5f7322b16399a01a0ee2a182e3150946fe7946358247)#68u5tv65",
    "active": false
  }
]

Before

{
  "code": -3,
  "message": "Missing required timestamp field for key"
}

After

{
  "code": -3,
  "message": "Missing required timestamp field for import request: {\"desc\":\"pkh(039dcc64c5c644baf0145a5f7322b16399a01a0ee2a182e3150946fe7946358247)#68u5tv65\",\"active\":false}"
}
## Motivation When `importdescriptors` is given multiple requests, a missing `timestamp` still fails the whole call with a static error (`Missing required timestamp field for key`). That does not say which request failed. #34861 is merged. Other parse failures are returned per item, but a missing or invalid timestamp is still a top-level RPC error from `GetImportTimestamp`. ## Solution Include the failing request in that error message. ## Example Request ```json [ { "desc": "wpkh([abcd1234/84h/1h/0h]tpub.../0/*)#x9abc123", "timestamp": 1710000000, "active": true, "range": [0, 100] }, { "desc": "pkh(039dcc64c5c644baf0145a5f7322b16399a01a0ee2a182e3150946fe7946358247)#68u5tv65", "active": false } ] ``` Before ```json { "code": -3, "message": "Missing required timestamp field for key" } ``` After ```json { "code": -3, "message": "Missing required timestamp field for import request: {\"desc\":\"pkh(039dcc64c5c644baf0145a5f7322b16399a01a0ee2a182e3150946fe7946358247)#68u5tv65\",\"active\":false}" } ```
DrahtBot commented 2026-05-06 16:34:07 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #31668 (Added rescan option for import descriptors by saikiran57)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35224 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35224.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35224#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) * [#31668](https://github.com/bitcoin/bitcoin/pull/31668) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/31668.svg"></sub> (Added rescan option for import descriptors by saikiran57) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: a773e1e33b349dc819b5a0edc1c7a4839dc73b48
Head: ad0c67a91e2fad45d40006dc7a3af592397bbe43

Findings

Suggestions

Test a missing timestamp in a multi-request batch (test/functional/wallet_importdescriptors.py:341, head)

The updated assertion calls test_importdesc(), which submits a one-element list and does not cover the motivating case: a valid earlier request followed by one with no timestamp. Add a direct multi-entry call and assert that the later item's safe identifier is reported.

Review coverage was incomplete.

Review limitations
  • adversarial_deepseek: Stage did not complete (ValueError).
  • verifier: No current in-repository production caller producing a private-descriptor request without a timestamp was identified, so real-world occurrence is unconfirmed. Whether a less-trusted party can read captured stderr or RPC-client logs is deployment-specific.
  • verifier: Finding withheld: Source evidence does not match the snapshot

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:1e40d4c29146a38cb238a037edaa35c22b13996a5383ed7a85e089a15d569009:c9412d948811529792d161d97aa6951829440e3d548b7c576bb8d4df4183e0d0 --> Base: `a773e1e33b349dc819b5a0edc1c7a4839dc73b48` Head: `ad0c67a91e2fad45d40006dc7a3af592397bbe43` ##### Findings **Suggestions** **Test a missing timestamp in a multi-request batch** (test/functional/wallet_importdescriptors.py:341, head) The updated assertion calls `test_importdesc()`, which submits a one-element list and does not cover the motivating case: a valid earlier request followed by one with no timestamp. Add a direct multi-entry call and assert that the later item's safe identifier is reported. Review coverage was incomplete. <details> <summary>Review limitations</summary> - adversarial_deepseek: Stage did not complete (ValueError). - verifier: No current in-repository production caller producing a private-descriptor request without a timestamp was identified, so real-world occurrence is unconfirmed. Whether a less-trusted party can read captured stderr or RPC-client logs is deployment-specific. - verifier: Finding withheld: Source evidence does not match the snapshot </details> [Full review report](<https://review.fish.foo/traces/35224-ad0c67a91e2fad45d40006dc7a3af592397bbe43-1310-3.html>)
kevkevinpal commented 2026-10-10 14:34:59 +00:00 (Migrated from github.com)

CI / 32 bit ARM (pull_request) failing seems unrelated to the change

[CI / 32 bit ARM (pull_request)](https://github.com/bitcoin/bitcoin/actions/runs/38059091090/job/114233559346?pr=35224) failing seems unrelated to the change
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35224
No description provided.