bank: Nostro reads the bank's callback, and the shop's bunq code is gone
All checks were successful
Deploy / build-deploy (push) Successful in 7m20s

The shadow run of 36a635f had Nostro's ReadCallback read a real
callback beside our own parser on 2026-11-25, for order CC-BCD155: the
same id, amount and reference, on the shop's own account. So the reader
takes over, and what this repo carried of bunq goes: the callback
parser, the payment-type table, the API client with its RSA signing,
`--pull-credits`, the mode that read the bank from the server with an
API key, and tools/register-bunq-webhook.sh.

The server now knows no bank. Catcrafts.Server-BankCallback.cpp is the
one unit that imports Nostro.Money: ReadBankCallback has a body read
and says what it comes to, CreditMethodFor says how a payment arrived.
Which bank it is is configuration: --banks= in project.cpp for what the
build can read, BANK_CALLBACK_BANK on the server for what arrives.

What changes for a running shop:

- The endpoint is configured with BANK_CALLBACK_PATH and
  BANK_CALLBACK_BANK; BUNQ_WEBHOOK_PATH is no longer read. Without the
  bank's name, or without TRANSFER_IBAN, the endpoint stays off and the
  startup log says so: one that answered 200 and credited nothing would
  look like working. Production's payments.env got both names before
  this was pushed.
- Only a payment on TRANSFER_IBAN is credited. A bank posts to whatever
  address any of its customers registered, so a callback about someone
  else's account can be the bank's own. Until now a payment in a
  callback was credited whichever account it was on.
- `via` says `internal` for a payment from another account at the bank
  itself, where it said `bunq`, and `card` where it would have said
  `MASTERCARD`. A kind without a word is still passed on as the bank
  wrote it, now only where that is a plain word.
- Every callback leaves one line in the log, `bank callback: credited
  ...` or `bank callback: nothing credited: <why>`, with nothing of the
  body in it beyond the credit.
- A line of the credits file may carry the bank's kind and the bank
  (`"bank":"bunq","kind":"EBA_SCT/SCT"`) in place of `method`, put into
  the ledger's words when the file is read. The pull script ships those
  and takes the bank's name from nostrod, so it holds no table of a
  bank's words either.

Also gone, with their last user: ParseAmountToMinor, PullCreditsInto
and the explicit -lcrypto (Crafter.Network names what it needs).

ShouldReadBankCallbacks replaces ShouldParseBunqPayments and
ShouldCompareCallbackReaders: what a callback comes to for each shape,
each method, the account and the sign, and that no note repeats
anything a body carried. ShouldReceiveBankCallbacks posts to the real
endpoint: an order settles from a callback, one from another account
quoting the same order does not pay for it, and a server without the
bank's name has no endpoint.

Built from scratch and run in a copy of this tree with crafter-build
6.4.1: the server and the wasm bundle build, and every suite passes but
ShouldServePostPages, which fails there for want of mirrored post media
and passed in CI on the commit before this. A dry run of the pull
script against nostrod gave 19 credits with their kinds.

Not tried: a real callback through the new handler, and `nostro
callbacks` against the registration that is in place, which was made
with the script this removes. deploy/README.md has the new setup.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-25 15:08:42 +01:00
commit 33ce8f45d8
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
24 changed files with 1218 additions and 2385 deletions

View file

@ -87,8 +87,8 @@ static Configuration* SharedLibrary(std::span<const std::string_view> args) {
// Catcrafts.ServerCore — every implementation unit of the server except
// main.cpp, as a static library. The split exists for the tests: a test can
// only LINK a library-type dependency (crafter-build exports -L/-l for
// libraries alone), and the bunq/EURC/Sendcloud parsers and the invoice
// builder all live here. The exe is main.cpp plus this library, so the
// libraries alone), and the bank-callback/EURC/Sendcloud readers and the
// invoice builder all live here. The exe is main.cpp plus this library, so the
// split costs nothing at deploy time.
//
// Same `static unique_ptr` convention as SharedLibrary, and the same warning:
@ -108,15 +108,14 @@ static Configuration* ServerCore(std::span<const std::string_view> args, Configu
std::array<fs::path, 1> ifaces = {
"server/interfaces/Catcrafts.Server",
};
std::array<fs::path, 11> impls = {
std::array<fs::path, 10> impls = {
"server/implementations/Catcrafts.Server-Http",
"server/implementations/Catcrafts.Server-Orders",
"server/implementations/Catcrafts.Server-Rails",
"server/implementations/Catcrafts.Server-Invoice",
"server/implementations/Catcrafts.Server-Eurc",
"server/implementations/Catcrafts.Server-Transfer",
"server/implementations/Catcrafts.Server-Bunq",
"server/implementations/Catcrafts.Server-CallbackShadow",
"server/implementations/Catcrafts.Server-BankCallback",
"server/implementations/Catcrafts.Server-Shipping",
"server/implementations/Catcrafts.Server-Mail",
"server/implementations/Catcrafts.Server-Financials",
@ -124,14 +123,12 @@ static Configuration* ServerCore(std::span<const std::string_view> args, Configu
core->GetInterfacesAndImplementations(ifaces, impls);
// The rails reach the outside world over TLS, which is what libssl is for.
// libcrypto is named EXPLICITLY again because the bunq credit source signs
// every request body with RSA-SHA256 through EVP: relying on it arriving as
// libssl's transitive dependency worked while nothing called EVP directly,
// and would break confusingly the moment a linker ordered them otherwise.
// On the lib rather than the exe because link flags propagate to consumers
// — the exe and every test get them from here.
// Nothing in this library calls libcrypto itself any more (the bank client
// that signed its requests through EVP is gone), so it is no longer named
// here: what Crafter.Network needs of it, Crafter.Network names. On the lib
// rather than the exe because link flags propagate to consumers — the exe
// and every test get them from here.
core->linkFlags.push_back("-lssl");
core->linkFlags.push_back("-lcrypto");
return core.get();
}
@ -180,13 +177,14 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
.args = netArgs,
});
// Nostro.Money: the part of Nostro (the bank library this shop's own
// bunq code is being replaced by) that reads what a bank posts to a
// callback's address. `--product=money` is that module alone: it holds
// no credential and brings no Crafter.Network, Crafter.DB or OpenSSL
// of its own, which is why it can sit in this server at all. Nostro's
// full library pins Crafter.Network at a commit and without QUIC, and
// loading it here would stop the build on two builds of one module.
// Nostro.Money: the part of Nostro (a bank library) that reads what a
// bank posts to a callback's address and says how a payment arrived.
// `--product=money` is that module alone: it holds no credential and
// brings no Crafter.Network, Crafter.DB or OpenSSL of its own, which
// is why it can sit in this server at all. Nostro's full library pins
// Crafter.Network at a commit and without QUIC, and loading it here
// would stop the build on two builds of one module. `--banks=` is the
// one place this build says which bank's formats it wants read.
//
// Named at the commit of the 1.1.0 release, not at a branch. This is
// code that reads claims about money, so what is built is what was
@ -262,8 +260,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
cfg.AddTest("ShouldFoldTheOrderLedger").Dependencies({ core, shared });
cfg.AddTest("ShouldIssueEurcAddresses").Dependencies({ core, shared });
cfg.AddTest("ShouldMatchBankTransfers").Dependencies({ core, shared });
cfg.AddTest("ShouldParseBunqPayments").Dependencies({ core, shared });
cfg.AddTest("ShouldCompareCallbackReaders").Dependencies({ core, shared });
cfg.AddTest("ShouldReadBankCallbacks").Dependencies({ core, shared });
// ── black-box suites (the tools/e2e.sh port) ──────────────────
// Each spawns the REAL binary — depending on &cfg is what builds it
@ -313,11 +310,9 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
.Timeout(std::chrono::seconds(180));
// The callback endpoint itself, over real HTTP: what the bank posts is
// credited by our own parser exactly as before, an order settles from
// it, and the shadow run of Nostro's reader beside it says what it
// made of the same body without being able to change any of that.
// No secret and no network, like the suite above. It waits out the
// reconciler once.
// read and credited, an order settles from it, and what is not a
// payment to the shop's own account credits nothing. No secret and no
// network, like the suite above. It waits out the reconciler once.
cfg.AddTest("ShouldReceiveBankCallbacks", harness)
.Dependencies({ &cfg, shared, network }).Args({ serverBin })
.Timeout(std::chrono::seconds(180));