From 54ec7ae895491ce9047e6589cc7d76bd8b44c226 Mon Sep 17 00:00:00 2001 From: Bitflash Date: Mon, 3 Aug 2026 10:49:25 -0300 Subject: wallet: wire -sendto into main(), where it never was (#119) CmdSendTo() has been in walletcmd.cpp since #115 and nothing declared it or called it. The flag was dead: `bitflash -sendto=ADDRESS,AMOUNT` started a node and said nothing, because an unrecognised argument is not an error here. The v1.2.14 notes announce it under "A headless node can finally spend", and the headless Linux binary is exactly the one that does not have it -- `-help` there lists /newaddress and stops. The published Windows binary does have it, because it was built from a working tree that carried these two files uncommitted. So the artifacts disagree with each other and neither matches the tag. This adds only what was missing: the declaration in walletcmd.h, the dispatch in main(), and the -help line. No behaviour change to CmdSendTo itself. Checked on a build of this branch, against a throwaway data directory: -help lists /sendto=ADDRESS,AMOUNT -sendto=NOTANADDRESS,1 "Not a valid address", exit 1 -sendto=,-5 "Not a valid amount", exit 1 -sendto=,999 refused on an empty wallet, exit 1 All five self-tests still pass. --- src/main_gui.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/main_gui.cpp') diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 1b72813..6164ad7 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -86,6 +86,8 @@ static void PrintUsage() printf(" anyone, so guard it like cash)\n"); printf(" /importwallet=FILE (load keys from such a file back in)\n"); printf(" /newaddress (print the next receiving address, then exit)\n"); + printf(" /sendto=ADDRESS,AMOUNT (spend from this wallet, then exit -- the\n"); + printf(" only way to send without the window)\n"); printf(" /newphrase (create a twelve-word recovery phrase for a\n"); printf(" wallet that has none, show it once, exit)\n"); printf(" /restorephrase=\"WORDS\" (rebuild this wallet from a phrase and scan\n"); @@ -388,6 +390,17 @@ int main(int argc, char* argv[]) return nRet; } + // -sendto -- the counterpart to -newaddress. Without it a headless node can + // be paid and can never pay: SendMoney() has been here since 0.1.0 and only + // the window ever reached it. + string strSendTo = argval2(argc, argv, "/sendto", "-sendto"); + if (!strSendTo.empty()) + { + int nRet = CmdSendTo(strSendTo); + DBFlush(true); + return nRet; + } + if (arg(argc,argv,"/recoveryaudit") || arg(argc,argv,"-recoveryaudit")) { int nRet = CmdRecoveryAudit(); -- cgit v1.2.3