upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-08-01 17:57:07 -0300
committerGitHub <noreply@github.com>2026-08-01 17:57:07 -0300
commit7de7ef89d3365f8f9c2eb2b6ed0193c3033e221c (patch)
treedba509ae6b245be76b88ad0ae467aeb997a85b4d /src/util.h
parentce59d8c72c667ce638bd12f37db26d8b3408a5d2 (diff)
wallet: create and restore a recovery phrase (#96)
Adds -newphrase, -restorephrase, -restoredepth, -newaddress and -showderived, plus the window buttons that reach the same code. Restore derives forward in batches of 100 and rescans after each, stopping when a whole batch turns up nothing; the phrase is shown on the terminal only, never in debug.log. Proved end to end on a live wallet: paid a derived address, deleted wallet.dat, restored from the twelve words and recovered the coin. Coins on the pre-seed default address do not come back, and the command says so.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 25ef118..d95d3ae 100644
--- a/src/util.h
+++ b/src/util.h
@@ -293,6 +293,33 @@ void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool fSp
293// Forward declaration -- defined in main.cpp 293// Forward declaration -- defined in main.cpp
294string GetAppDir(); 294string GetAppDir();
295 295
296// Give a command-line operation somewhere to print.
297//
298// The Windows binary is linked -mwindows and starts with no console, so stdout
299// goes nowhere even when it was launched from a terminal. Commands that report
300// to the person who typed them -- the self-tests, the wallet phrase commands --
301// call this first.
302//
303// Only when there is nowhere for stdout to go already: if the caller redirected
304// it to a file or a pipe, that handle is inherited and works, and reopening it
305// on CONOUT$ would take the output away from the file and put it on the screen.
306inline void AttachTerminal()
307{
308#ifdef _WIN32
309 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
310 if (hOut != NULL && hOut != INVALID_HANDLE_VALUE)
311 return;
312 if (AttachConsole(ATTACH_PARENT_PROCESS))
313 {
314 // Return values ignored on purpose: if the reopen fails there is
315 // nowhere left to report it, and the exit status still carries the
316 // result.
317 freopen("CONOUT$", "w", stdout);
318 freopen("CONOUT$", "w", stderr);
319 }
320#endif
321}
322
296inline int OutputDebugStringF(const char* pszFormat, ...) BF_FORMAT(1, 2); 323inline int OutputDebugStringF(const char* pszFormat, ...) BF_FORMAT(1, 2);
297 324
298inline int OutputDebugStringF(const char* pszFormat, ...) 325inline int OutputDebugStringF(const char* pszFormat, ...)