upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/walletcmd.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/walletcmd.h')
-rw-r--r--src/walletcmd.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/walletcmd.h b/src/walletcmd.h
new file mode 100644
index 0000000..04d3fb7
--- /dev/null
+++ b/src/walletcmd.h
@@ -0,0 +1,65 @@
1// Copyright (c) 2026 Bitflash developers
2// Distributed under the MIT/X11 software license.
3//
4// Recovery-phrase commands. Both run against a loaded wallet and then exit;
5// neither starts the node.
6
7#ifndef BITFLASH_WALLETCMD_H
8#define BITFLASH_WALLETCMD_H
9
10#include <string>
11
12// Create a phrase for a wallet that does not have one, install the seed, and
13// show the words once. Refuses if a phrase already exists. Returns 0 on success.
14int CmdNewPhrase();
15
16// Install the seed a phrase describes, derive forward looking for used
17// addresses, and rescan the chain so their coins appear. Returns 0 on success.
18int CmdRestorePhrase(const std::string& strMnemonic, int nMinDepth = 0);
19
20// Called once per batch with how many addresses have been derived so far and
21// how many transactions the wallet now holds.
22typedef void (*RestoreProgressFn)(void* pArg, int nDerived, int nRecovered);
23
24// The restore itself, shared by the command and the GUI so the two cannot
25// drift apart. Returns false without touching the wallet if the chain is not
26// loaded or the phrase is not valid.
27bool RestoreFromPhrase(const std::string& strMnemonic,
28 int nMinDepth,
29 RestoreProgressFn fnProgress,
30 void* pArg,
31 std::string& strErrorRet,
32 int& nRecoveredRet,
33 int& nDerivedRet);
34
35// Restore scans stop only after the requested depth is reached. BIP44 has more
36// than one branch, so the depth has to be satisfied per branch, not by summing
37// receive + change + compatibility keys.
38bool RestoreScanReachedDepth(int nSchema,
39 unsigned int nReceiveNext,
40 unsigned int nChangeNext,
41 unsigned int nLegacyNext,
42 int nStopDepth);
43
44// Take the next address from the key pool and print it. With a recovery phrase
45// installed the address is derived, so the phrase can bring back whatever is
46// paid to it.
47int CmdNewAddress();
48
49// Diagnostic: print the first nCount addresses this wallet's phrase derives.
50int CmdShowDerived(int nCount);
51
52// Diagnostic: print whether the currently spendable wallet balance is covered
53// by the installed recovery phrase or still depends on wallet.dat-only keys.
54int CmdRecoveryAudit();
55
56// Rewrite wallet.dat so private keys and the HD seed are encrypted with the
57// given passphrase. Returns 0 on success and exits without starting the node.
58int CmdEncryptWallet(const std::string& strPassphrase);
59
60// Spend, from the command line. Until now the only way to send was the window,
61// so a headless node could be paid and could never pay -- it could hold a
62// balance it had no way to move. strArg is "ADDRESS,AMOUNT".
63int CmdSendTo(const std::string& strArg);
64
65#endif