2026-11-01 18:35:23 +01:00
// SPDX-License-Identifier: LGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
2026-10-06 15:39:17 +02:00
import std ;
import Nostro ;
using namespace Nostro ;
2026-11-01 18:35:23 +01:00
namespace {
constexpr std : : string_view usage = R " (usage:
nostro connectors list connectors and whether they work
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
nostro connectors add bunq [ allowed ips ] asks for the API key ; ips default to *
2026-11-01 18:35:23 +01:00
nostro connectors add bunq - oauth < client id > < redirect uri > [ - - sandbox ] asks for the client secret
nostro connectors remove < name or number > log out and forget a connector and its stored transactions
nostro accounts
nostro transactions < account > [ - - search text ] [ - - amount n ] [ - - from date ] [ - - to date ] [ - - limit n ]
nostro send < account > < to > < name > < amount > [ description ]
nostro request < account > < from > < name > < amount > [ description ]
nostro requests < account > [ revoke < id > ] requests for money you sent
nostro incoming < account > [ accept | reject < id > ] requests for money you received
nostro schedule < account > < to > < name > < amount > < start date > < once | daily | weekly | monthly | yearly > [ description ] [ - - every n ] [ - - until date ]
nostro scheduled < account > [ cancel < id > ]
nostro draft < account > < to > < name > < amount > [ description ]
nostro drafts < account > [ accept | reject < id > ]
nostro cards [ freeze | unfreeze | lost | stolen < card id > ]
nostro checkout account [ < account > ] the account apps may ask you to pay from at checkout
< account > is an account ' s name or IBAN . < to > and < from > are an IBAN , an e - mail address , or a phone number
starting with + . Amounts are in the smallest unit of the account ' s currency : 1250 is 12.50 . Dates are
YYYY - MM - DD or " YYYY-MM-DD hh:mm " , in local time . A sandbox API key is recognised by its prefix .
fix: close what the security review before the first release found
A review of the tree and its history before they are published found no
key and no bank data in them. It did find these, each closed here.
The password dialog could be emptied (daemon). Shown(), which makes a
payee's name fit for polkit's dialog, let an & through. GNOME's older
agent (polkit-gnome) and MATE's put the message into Pango markup
unescaped, where a bare & fails to parse and leaves the dialog without
a message: paying "Tom & Jerry", or an order an app names so at
checkout, asked for the password and showed no amount and no payee.
Line and paragraph separators passed too. Shown() now shows & as +,
leaves out what draws nothing or places text (control and format
characters, the separators, what Unicode ignores by default, private
use) and makes any run of spaces one space. An address is held to it
instead of made fit: an e-mail address the dialog could not show
unchanged is refused before anyone is asked, since "a&b@..." shown as
"a+b@..." is somebody else's address.
A refused caller could look (daemon). A call that names an account, a
card, a request, a draft or a connector had it looked up, at the bank
where that takes it, before polkit was asked. So a caller polkit
refused was told whether it was there ("no account is called ..."),
and had the bank asked. Such a call now asks for View first
(HandleLookup), a call that only sees looks its account up after its
yes, and the connectors are read, which refreshes the accounts at the
bank, on the first yes instead of on the first call.
An app at checkout was told too much (checkout). The refusal of an
order's reference with another amount named the amount on record, and
a refusal by the bank carried the call it answered, whose path has the
user's and the account's ids at bunq. Neither does now.
A key typed by hand could be read off the screen (app). The line under
a key field showed how the key begins and its last four characters,
which is every character of it as it is typed. It shows how the key
begins and how long it is.
Every change asks for the password (packaging, app). Change, the
action for what changes something and pays nobody, passed without a
password in an active session, so any program of the user's could
cancel a scheduled payment, ask for money in their name or freeze a
card. It asks now (auth_self), a draft saved and a card frozen
included: only View passes as shipped, and loosening is an
administrator's rule, of which the README has an example. The app says
of every change where it is confirmed (AsksPassword is gone), and the
request form sends on its button as the pay form does: its review
sheet would be a second confirmation of what the dialog confirms.
What is built is what was tested (build). Crafter.Network, Crafter.DB
and Crafter.LintRules are named at the commits the tests ran against.
Crafter.Thread still follows its branch, which Crafter.Network's own
project file names, and so does Crafter.Network in the app's debug
build, where Crafter.Debug names it too and crafter-build refuses a
module built twice. lib/json.hpp was nlohmann/json's develop branch at
95e9a593 less its last newline, and called 3.12.0: it is that file
byte for byte now, and called what it is.
The published contract changes with this, before any release (design
rule 10): an e-mail address the dialog cannot show as it is is
refused, a call that looks something up needs View as well as its own
action, the checkout's errors say less, and the policy asks for the
password for Change. The XML, the policy and ShouldServeEveryUser,
which now holds the policy to its defaults, change together.
Reproduced and verified on the fake bus and the fake bunq. The new
checks of ShouldServeEveryUser fail on the worker of before (50 of
them: the & shown, the lookups answered, the bank asked) and pass now.
crafter-build test (17 tests), lint for the library, the app and the
fake system, and tests/coverage.sh (every line, function and region)
pass. Looked at on the made-up system, 360x760 dp at scale 2, dark, on
KDE Wayland: the key form with a key typed, the request form with its
wait and its result, a card frozen, and About. No picture in the
README shows a screen that changed.
Not tried: bunq's sandbox, a real polkit agent, the Flatpak builds.
The README's example rule ran against a stand-in for polkit's rule
engine only.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
2026-11-19 16:09:48 +01:00
nostrod does the work , and asks for your password before it pays or changes anything , a checkout included . ) " ;
2026-11-01 18:35:23 +01:00
// Positional arguments, with "--name value" options (and the "--sandbox" and "--help" flags) taken out wherever they are.
struct Arguments {
std : : vector < std : : string_view > positional ;
std : : map < std : : string_view , std : : string_view , std : : less < > > options ;
bool sandbox = false ;
explicit Arguments ( std : : span < const std : : string_view > args ) {
for ( std : : size_t i = 0 ; i < args . size ( ) ; i + + ) {
const std : : string_view arg = args [ i ] ;
if ( arg = = " --sandbox " ) {
sandbox = true ;
} else if ( arg = = " --help " ) {
positional . push_back ( " help " ) ;
} else if ( arg . starts_with ( " -- " ) & & arg . size ( ) > 2 ) {
if ( i + 1 > = args . size ( ) ) {
throw std : : invalid_argument ( std : : format ( " {} needs a value " , arg ) ) ;
2026-10-06 15:39:17 +02:00
}
2026-11-01 18:35:23 +01:00
options [ arg ] = args [ + + i ] ;
2026-10-06 15:39:17 +02:00
} else {
2026-11-01 18:35:23 +01:00
positional . push_back ( arg ) ;
2026-10-06 15:39:17 +02:00
}
2026-11-01 18:35:23 +01:00
}
}
std : : string_view At ( std : : size_t index , std : : string_view what ) const {
if ( index > = positional . size ( ) ) {
throw std : : invalid_argument ( std : : format ( " {} not provided " , what ) ) ;
}
return positional [ index ] ;
}
std : : string_view Or ( std : : size_t index , std : : string_view fallback ) const {
return index < positional . size ( ) ? positional [ index ] : fallback ;
}
std : : optional < std : : string_view > Option ( std : : string_view name ) const {
const auto it = options . find ( name ) ;
return it = = options . end ( ) ? std : : nullopt : std : : optional < std : : string_view > ( it - > second ) ;
}
} ;
template < typename T >
T ParseNumber ( std : : string_view text , std : : string_view what ) {
T value { } ;
const std : : from_chars_result result = std : : from_chars ( text . data ( ) , text . data ( ) + text . size ( ) , value ) ;
if ( result . ec ! = std : : errc ( ) | | result . ptr ! = text . data ( ) + text . size ( ) ) {
throw std : : invalid_argument ( std : : format ( " {} '{}' is not a whole number " , what , text ) ) ;
}
return value ;
}
// Amounts are whole numbers of the currency's minor unit; "12.50" is refused rather than guessed at.
std : : int64_t ParseAmountArgument ( std : : string_view text ) {
if ( text . contains ( ' . ' ) | | text . contains ( ' , ' ) ) {
throw std : : invalid_argument ( std : : format ( " amount '{}': give it in the smallest unit, 1250 for 12.50 " , text ) ) ;
}
return ParseNumber < std : : int64_t > ( text , " amount " ) ;
}
// The arguments a payment, a draft, a schedule and a request share, read in order so a missing one is named the
// same way every time.
struct Payment {
std : : string_view account ;
std : : string_view counterparty ;
std : : string_view name ;
std : : int64_t amount = 0 ;
std : : string_view description ;
Payment ( const Arguments & args , std : : string_view counterpartyIs , std : : string_view nameIs , std : : size_t descriptionAt ) {
account = args . At ( 1 , " account " ) ;
counterparty = args . At ( 2 , counterpartyIs ) ;
name = args . At ( 3 , nameIs ) ;
amount = ParseAmountArgument ( args . At ( 4 , " amount " ) ) ;
description = args . Or ( descriptionAt , " " ) ;
}
} ;
void ListConnectors ( Client & client ) {
std : : size_t number = 1 ;
for ( const ConnectorSummary & connector : client . Connectors ( ) ) {
std : : println ( " {} \t {} \t {} \t {} \t {} \t {} " , number + + , connector . name , connector . bank , connector . environment , connector . auth , connector . working ? " ok " : " failing " ) ;
}
}
void AddBunq ( Client & client , const Arguments & args ) {
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
// An API key says itself which environment it is of, by how it starts: there is nothing to choose, and a
// real key is not to be sent to the sandbox by a flag. Said before the key is asked for.
if ( args . sandbox ) {
throw std : : invalid_argument ( " --sandbox goes with bunq-oauth: an API key is a sandbox key when it starts with sandbox_ " ) ;
}
2026-11-01 18:35:23 +01:00
// Read at a prompt, or from stdin, never from the command line: every local user can read a process's
// arguments, and polkit writes them to the journal.
const std : : string key = ReadSecret ( " bunq API key: " ) ;
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
const AddedConnector added = client . AddBunq ( key , args . Or ( 3 , " * " ) , " " ) ;
2026-11-01 18:35:23 +01:00
std : : println ( " added {} ({}, {} accounts) " , added . name , added . environment , added . accounts ) ;
}
void AddBunqOAuth ( Client & client , const Arguments & args ) {
const std : : string_view clientId = args . At ( 3 , " client id " ) ;
const std : : string_view redirectUri = args . At ( 4 , " redirect uri " ) ;
const BunqEnvironment environment = args . sandbox ? BunqEnvironment : : Sandbox : BunqEnvironment : : Production ;
const std : : string clientSecret = ReadSecret ( " OAuth client secret: " ) ;
// `state` ties the redirect to this request: a code from anyone else's authorization is refused.
const std : : string state = Crypto : : RandomHex ( 16 ) ;
std : : println ( " Open this address and approve the connection with the bunq app: \n \n {} \n " , BunqConnector : : OAuthAuthorizationUrl ( environment , clientId , redirectUri , state ) ) ;
std : : println ( " Then paste the address your browser was sent to: " ) ;
std : : string redirected ;
if ( ! std : : getline ( std : : cin , redirected ) ) {
throw std : : runtime_error ( " no address given " ) ;
}
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
const std : : string code = BunqConnector : : OAuthCodeFromRedirect ( redirected , state ) ;
2026-11-01 18:35:23 +01:00
// nostrod exchanges the code for its token and keeps it; the token never comes here.
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
const AddedConnector added = client . AddBunqOAuth ( args . sandbox ? " sandbox " : " production " , clientId , clientSecret , redirectUri , code ) ;
2026-11-01 18:35:23 +01:00
std : : println ( " added {} through OAuth ({}, {} accounts) " , added . name , added . environment , added . accounts ) ;
}
void Connectors ( Client & client , const Arguments & args ) {
const std : : string_view verb = args . Or ( 1 , " " ) ;
if ( verb . empty ( ) ) {
ListConnectors ( client ) ;
} else if ( verb = = " add " ) {
const std : : string_view type = args . At ( 2 , " connector type " ) ;
if ( type = = " bunq " ) {
AddBunq ( client , args ) ;
} else if ( type = = " bunq-oauth " ) {
AddBunqOAuth ( client , args ) ;
2026-10-06 15:39:17 +02:00
} else {
2026-11-01 18:35:23 +01:00
throw std : : invalid_argument ( std : : format ( " unknown connector type '{}' " , type ) ) ;
2026-10-06 15:39:17 +02:00
}
2026-11-01 18:35:23 +01:00
} else if ( verb = = " remove " ) {
std : : println ( " removed {} " , client . RemoveConnector ( args . At ( 2 , " connector name " ) ) ) ;
2026-10-06 15:39:17 +02:00
} else {
2026-11-01 18:35:23 +01:00
throw std : : invalid_argument ( std : : format ( " unknown connectors command '{}' " , verb ) ) ;
}
}
2026-10-31 20:50:57 +01:00
2026-11-01 18:35:23 +01:00
void ListAccounts ( Client & client , const Arguments & ) {
for ( const ConnectorAccounts & connector : client . Accounts ( ) ) {
std : : println ( " {} \t {} " , connector . name , connector . bank ) ;
for ( const Account & account : connector . accounts ) {
std : : println ( " \t {} " , account ) ;
2026-10-31 20:50:57 +01:00
}
2026-11-01 18:35:23 +01:00
}
}
2026-10-31 20:50:57 +01:00
2026-11-01 18:35:23 +01:00
void ListTransactions ( Client & client , const Arguments & args ) {
TransactionQuery query ;
query . search = args . Option ( " --search " ) . value_or ( " " ) ;
if ( const std : : optional < std : : string_view > amount = args . Option ( " --amount " ) ) {
query . amount = ParseNumber < std : : int64_t > ( * amount , " amount " ) ;
}
if ( const std : : optional < std : : string_view > from = args . Option ( " --from " ) ) {
query . from = ParseLocalDate ( * from ) ;
}
if ( const std : : optional < std : : string_view > to = args . Option ( " --to " ) ) {
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
query . to = ParseLocalDateEnd ( * to ) ;
2026-11-01 18:35:23 +01:00
}
if ( const std : : optional < std : : string_view > limit = args . Option ( " --limit " ) ) {
query . limit = ParseNumber < std : : size_t > ( * limit , " limit " ) ;
}
for ( const Transaction & transaction : client . Transactions ( args . At ( 1 , " account " ) , query ) ) {
std : : println ( " {} " , transaction ) ;
2026-10-06 15:39:17 +02:00
}
2026-11-01 18:35:23 +01:00
}
2026-10-31 20:50:57 +01:00
2026-11-01 18:35:23 +01:00
void Send ( Client & client , const Arguments & args ) {
const Payment payment ( args , " recipient " , " recipient name " , 5 ) ;
try {
const Created sent = client . Send ( payment . account , payment . counterparty , payment . name , payment . amount , payment . description ) ;
std : : println ( " sent {} to {} (payment {}) " , FormatMoney ( payment . amount , sent . currency ) , payment . name , sent . id ) ;
} catch ( const DaemonError & e ) {
// bunq lets an OAuth connection pay between the user's own accounts only.
if ( e . name = = Bus : : errorOAuthCannotPay ) {
throw std : : runtime_error ( std : : format ( " {} \n This connector was added through OAuth, which can only pay your own accounts: `nostro draft` makes a payment to approve in the bunq app. " , e . what ( ) ) ) ;
2026-10-31 20:50:57 +01:00
}
2026-11-01 18:35:23 +01:00
throw ;
}
}
void Request ( Client & client , const Arguments & args ) {
const Payment payment ( args , " who to ask " , " their name " , 5 ) ;
std : : println ( " {} " , client . Request ( payment . account , payment . counterparty , payment . name , payment . amount , payment . description ) ) ;
}
void Requests ( Client & client , const Arguments & args ) {
const std : : string_view account = args . At ( 1 , " account " ) ;
if ( args . Or ( 2 , " " ) = = " revoke " ) {
client . RevokeRequest ( account , ParseNumber < std : : uint64_t > ( args . At ( 3 , " request id " ) , " request id " ) ) ;
std : : println ( " revoked request {} " , args . At ( 3 , " " ) ) ;
return ;
}
for ( const BunqPaymentRequest & request : client . Requests ( account ) ) {
std : : println ( " {} " , request ) ;
}
}
void Incoming ( Client & client , const Arguments & args ) {
const std : : string_view account = args . At ( 1 , " account " ) ;
const std : : string_view verb = args . Or ( 2 , " " ) ;
if ( verb = = " accept " | | verb = = " reject " ) {
client . RespondToRequest ( account , ParseNumber < std : : uint64_t > ( args . At ( 3 , " request id " ) , " request id " ) , verb = = " accept " ) ;
std : : println ( " {} request {} " , verb = = " accept " ? " paid " : " rejected " , args . At ( 3 , " " ) ) ;
return ;
}
for ( const BunqIncomingRequest & request : client . IncomingRequests ( account ) ) {
std : : println ( " {} " , request ) ;
}
}
void Schedule ( Client & client , const Arguments & args ) {
const Payment payment ( args , " recipient " , " recipient name " , 7 ) ;
BunqSchedule schedule ;
schedule . start = ParseLocalDate ( args . At ( 5 , " start date " ) ) ;
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
schedule . unit = BunqSchedule : : UnitFromWord ( args . At ( 6 , " recurrence " ) ) ;
2026-11-01 18:35:23 +01:00
if ( const std : : optional < std : : string_view > every = args . Option ( " --every " ) ) {
schedule . every = ParseNumber < std : : uint32_t > ( * every , " --every " ) ;
}
if ( const std : : optional < std : : string_view > until = args . Option ( " --until " ) ) {
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
schedule . end = ParseLocalDateEnd ( * until ) ;
2026-11-01 18:35:23 +01:00
}
const Created scheduled = client . Schedule ( payment . account , payment . counterparty , payment . name , payment . amount , payment . description , schedule ) ;
std : : println ( " scheduled {} to {} (schedule {}) " , FormatMoney ( payment . amount , scheduled . currency ) , payment . name , scheduled . id ) ;
}
void Scheduled ( Client & client , const Arguments & args ) {
const std : : string_view account = args . At ( 1 , " account " ) ;
if ( args . Or ( 2 , " " ) = = " cancel " ) {
client . CancelScheduledPayment ( account , ParseNumber < std : : uint64_t > ( args . At ( 3 , " schedule id " ) , " schedule id " ) ) ;
std : : println ( " cancelled schedule {} " , args . At ( 3 , " " ) ) ;
return ;
}
for ( const BunqScheduledPayment & scheduled : client . ScheduledPayments ( account ) ) {
std : : println ( " {} " , scheduled ) ;
}
}
void Draft ( Client & client , const Arguments & args ) {
const Payment payment ( args , " recipient " , " recipient name " , 5 ) ;
const Created drafted = client . Draft ( payment . account , payment . counterparty , payment . name , payment . amount , payment . description ) ;
std : : println ( " drafted {} to {} (draft {}); it is paid once accepted " , FormatMoney ( payment . amount , drafted . currency ) , payment . name , drafted . id ) ;
}
void Drafts ( Client & client , const Arguments & args ) {
const std : : string_view account = args . At ( 1 , " account " ) ;
const std : : string_view verb = args . Or ( 2 , " " ) ;
if ( verb = = " accept " | | verb = = " reject " ) {
client . RespondToDraftPayment ( account , ParseNumber < std : : uint64_t > ( args . At ( 3 , " draft id " ) , " draft id " ) , verb = = " accept " ) ;
std : : println ( " {} draft {} " , verb = = " accept " ? " accepted " : " rejected " , args . At ( 3 , " " ) ) ;
return ;
}
for ( const BunqDraftPayment & draft : client . DraftPayments ( account ) ) {
std : : println ( " {} " , draft ) ;
}
}
void Cards ( Client & client , const Arguments & args ) {
const std : : string_view verb = args . Or ( 1 , " " ) ;
if ( verb . empty ( ) ) {
for ( const ConnectorCards & connector : client . Cards ( ) ) {
std : : println ( " {} \t {} " , connector . name , connector . bank ) ;
for ( const BunqCard & card : connector . cards ) {
std : : println ( " \t {} " , card ) ;
2026-10-06 15:39:17 +02:00
}
}
2026-11-01 18:35:23 +01:00
return ;
}
const std : : map < std : : string_view , std : : string_view > statuses = { { " freeze " , " DEACTIVATED " } , { " unfreeze " , " ACTIVE " } , { " lost " , " LOST " } , { " stolen " , " STOLEN " } } ;
const auto status = statuses . find ( verb ) ;
if ( status = = statuses . end ( ) ) {
throw std : : invalid_argument ( std : : format ( " unknown card action '{}' " , verb ) ) ;
}
const std : : uint64_t id = ParseNumber < std : : uint64_t > ( args . At ( 2 , " card id " ) , " card id " ) ;
const BunqCard card = client . SetCardStatus ( id , status - > second ) ;
feat(app): add the Nostro app, a window for phones and desktops
Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.
- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
--sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.
The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
without asking the bank. The app searches with it; before, every search was
a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
as DEACTIVATED however well it pays, and leaves it as it is when asked,
without an error.
The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.
Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.
Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 12:27:14 +01:00
card . ExpectStatus ( status - > second ) ;
2026-11-01 18:35:23 +01:00
std : : println ( " card {} is now {} " , id , card . status ) ;
}
// Apps pay at checkout from one account, and the user confirms each payment with their password.
void CheckoutAccount ( Client & client , const Arguments & args ) {
const std : : string_view verb = args . At ( 1 , " checkout command " ) ;
if ( verb ! = " account " ) {
throw std : : invalid_argument ( std : : format ( " unknown checkout command '{}' " , verb ) ) ;
}
if ( args . positional . size ( ) > 2 ) {
std : : println ( " checkouts pay from {} " , client . SetDefaultCheckoutAccount ( args . positional [ 2 ] ) ) ;
} else if ( const std : : optional < Account > chosen = client . DefaultCheckoutAccount ( ) ) {
std : : println ( " {} " , * chosen ) ;
2026-10-06 15:39:17 +02:00
} else {
2026-11-01 18:35:23 +01:00
std : : println ( " no account pays at checkout: `nostro checkout account <account>` chooses one " ) ;
2026-10-06 15:39:17 +02:00
}
}
2026-11-01 18:35:23 +01:00
std : : int32_t Run ( std : : span < const std : : string_view > arguments ) {
const Arguments args ( arguments ) ;
if ( args . positional . empty ( ) ) {
std : : println ( " {} " , usage ) ;
return 1 ;
}
const std : : string_view cmd = args . positional [ 0 ] ;
if ( cmd = = " help " ) {
std : : println ( " {} " , usage ) ;
return 0 ;
}
const std : : map < std : : string_view , void ( * ) ( Client & , const Arguments & ) > commands = {
{ " connectors " , Connectors } , { " accounts " , ListAccounts } , { " transactions " , ListTransactions } ,
{ " send " , Send } , { " request " , Request } , { " requests " , Requests } , { " incoming " , Incoming } ,
{ " schedule " , Schedule } , { " scheduled " , Scheduled } , { " draft " , Draft } , { " drafts " , Drafts } , { " cards " , Cards } ,
{ " checkout " , CheckoutAccount } ,
} ;
const auto command = commands . find ( cmd ) ;
if ( command = = commands . end ( ) ) {
std : : println ( std : : cerr , " unknown command '{}' \n \n {} " , cmd , usage ) ;
return 1 ;
}
Client client = Client : : System ( ) ;
command - > second ( client , args ) ;
// The library's warnings during the call, such as a connector that could not be reached.
for ( const std : : string & note : client . TakeNotes ( ) ) {
std : : println ( std : : cerr , " {} " , note ) ;
}
return 0 ;
}
}
// main's signature is C's; past it the arguments are string views.
// lint-disable-next-line no-char-pointer
int main ( int argc , char * argv [ ] ) {
std : : vector < std : : string_view > arguments ;
for ( std : : int32_t i = 1 ; i < argc ; i + + ) {
arguments . emplace_back ( argv [ i ] ) ;
}
try {
return Run ( arguments ) ;
} catch ( const std : : exception & e ) {
std : : println ( std : : cerr , " error: {} " , e . what ( ) ) ;
return 1 ;
}
}