| 1627 | } |
| 1628 | |
| 1629 | RPCHelpMan importdescriptors() |
| 1630 | { |
| 1631 | return RPCHelpMan{"importdescriptors", |
| 1632 | "\nImport descriptors. This will trigger a rescan of the blockchain based on the earliest timestamp of all descriptors being imported. Requires a new wallet backup.\n" |
| 1633 | "\nNote: This call can take over an hour to complete if using an early timestamp; during that time, other rpc calls\n" |
| 1634 | "may report that the imported keys, addresses or scripts exist but related transactions are still missing.\n", |
| 1635 | { |
| 1636 | {"requests", RPCArg::Type::ARR, RPCArg::Optional::NO, "Data to be imported", |
| 1637 | { |
| 1638 | {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", |
| 1639 | { |
| 1640 | {"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "Descriptor to import."}, |
| 1641 | {"active", RPCArg::Type::BOOL, RPCArg::Default{false}, "Set this descriptor to be the active descriptor for the corresponding output type/externality"}, |
| 1642 | {"range", RPCArg::Type::RANGE, RPCArg::Optional::OMITTED, "If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import"}, |
| 1643 | {"next_index", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "If a ranged descriptor is set to active, this specifies the next index to generate addresses from"}, |
| 1644 | {"timestamp", RPCArg::Type::NUM, RPCArg::Optional::NO, "Time from which to start rescanning the blockchain for this descriptor, in " + UNIX_EPOCH_TIME + "\n" |
| 1645 | " Use the string \"now\" to substitute the current synced blockchain time.\n" |
| 1646 | " \"now\" can be specified to bypass scanning, for outputs which are known to never have been used, and\n" |
| 1647 | " 0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest timestamp\n" |
| 1648 | " of all descriptors being imported will be scanned.", |
| 1649 | /* oneline_description */ "", {"timestamp | \"now\"", "integer / string"} |
| 1650 | }, |
| 1651 | {"internal", RPCArg::Type::BOOL, RPCArg::Default{false}, "Whether matching outputs should be treated as not incoming payments (e.g. change)"}, |
| 1652 | {"label", RPCArg::Type::STR, RPCArg::Default{""}, "Label to assign to the address, only allowed with internal=false. Disabled for ranged descriptors"}, |
| 1653 | }, |
| 1654 | }, |
| 1655 | }, |
| 1656 | "\"requests\""}, |
| 1657 | }, |
| 1658 | RPCResult{ |
| 1659 | RPCResult::Type::ARR, "", "Response is an array with the same size as the input that has the execution result", |
| 1660 | { |
| 1661 | {RPCResult::Type::OBJ, "", "", |
| 1662 | { |
| 1663 | {RPCResult::Type::BOOL, "success", ""}, |
| 1664 | {RPCResult::Type::ARR, "warnings", /*optional=*/true, "", |
| 1665 | { |
| 1666 | {RPCResult::Type::STR, "", ""}, |
| 1667 | }}, |
| 1668 | {RPCResult::Type::OBJ, "error", /*optional=*/true, "", |
| 1669 | { |
| 1670 | {RPCResult::Type::ELISION, "", "JSONRPC error"}, |
| 1671 | }}, |
| 1672 | }}, |
| 1673 | } |
| 1674 | }, |
| 1675 | RPCExamples{ |
| 1676 | HelpExampleCli("importdescriptors", "'[{ \"desc\": \"<my descriptor>\", \"timestamp\":1455191478, \"internal\": true }, " |
| 1677 | "{ \"desc\": \"<my desccriptor 2>\", \"label\": \"example 2\", \"timestamp\": 1455191480 }]'") + |
| 1678 | HelpExampleCli("importdescriptors", "'[{ \"desc\": \"<my descriptor>\", \"timestamp\":1455191478, \"active\": true, \"range\": [0,100], \"label\": \"<my bech32 wallet>\" }]'") |
| 1679 | }, |
| 1680 | [&](const RPCHelpMan& self, const JSONRPCRequest& main_request) -> UniValue |
| 1681 | { |
| 1682 | std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(main_request); |
| 1683 | if (!pwallet) return NullUniValue; |
| 1684 | CWallet& wallet{*pwallet}; |
| 1685 | |
| 1686 | // Make sure the results are valid at least up to the most recent block |
nothing calls this directly
no test coverage detected