bank: run Nostro's callback reader beside ours, as a shadow
All checks were successful
Deploy / build-deploy (push) Successful in 7m33s

ParseBunqCallback is to be replaced by ReadCallback of Nostro.Money
(Nostro 1.1.0), so that this repo stops carrying bunq's wire format.
That reader is stricter than ours: it wants a time, a counterparty and
the account's own IBAN where ours reads four members, and nobody has
run it on a callback bunq really sent. Ours has settled real payments
since 2026-08. So before anything is swapped, both run.

- The handler is untouched and still decides alone. Once it has
  answered and written its credit, Nostro's reader reads the same body
  and one line goes to the log: `bank callback shadow: AGREE ...` when
  the id, the amount and the reference are the same in both readings,
  and `DIFFER ...` with what parted them otherwise.
- The line carries no payment data: no id, amount, name or reference,
  only whether values match and a few fixed words. A body holds the
  payer's name and IBAN, and may repeat the secret address.
- It is on wherever BUNQ_WEBHOOK_PATH is set, with no setting of its
  own.
- project.cpp takes Nostro with --product=money --banks=bunq, at the
  commit of its 1.1.0 release: the module alone, which brings no
  credential and no Crafter.Network, Crafter.DB or OpenSSL of its own.

ShouldCompareCallbackReaders pins every verdict, and that none repeats
anything a body carried. ShouldReceiveBankCallbacks posts callbacks to
the real endpoint: an order settles from one, a payment Nostro's reader
refuses is credited all the same, and the server's log holds nothing of
what was posted.

Built 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 the same way without this change
where the post media is not mirrored. The binary needs the same shared
libraries as before.

Temporary: once real payments read AGREE the reader takes over, and
this goes together with ParseBunqCallback. deploy/README.md says how to
read the result.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-25 14:21:55 +01:00
commit 36a635fd48
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
8 changed files with 906 additions and 5 deletions

View file

@ -94,7 +94,7 @@ static Configuration* SharedLibrary(std::span<const std::string_view> args) {
// Same `static unique_ptr` convention as SharedLibrary, and the same warning:
// cfg.dependencies holds a raw pointer, so the Configuration must outlive
// CrafterBuildProject.
static Configuration* ServerCore(std::span<const std::string_view> args, Configuration* network) {
static Configuration* ServerCore(std::span<const std::string_view> args, Configuration* network, Configuration* money) {
static auto core = std::make_unique<Configuration>();
// Same idempotence rule as SharedLibrary — see the warning there.
if (!core->name.empty()) return core.get();
@ -103,12 +103,12 @@ static Configuration* ServerCore(std::span<const std::string_view> args, Configu
core->outputName = "Catcrafts.ServerCore";
ApplyStandardArgs(*core, args);
core->type = ConfigurationType::LibraryStatic;
core->dependencies = { SharedLibrary(args), network };
core->dependencies = { SharedLibrary(args), network, money };
std::array<fs::path, 1> ifaces = {
"server/interfaces/Catcrafts.Server",
};
std::array<fs::path, 10> impls = {
std::array<fs::path, 11> impls = {
"server/implementations/Catcrafts.Server-Http",
"server/implementations/Catcrafts.Server-Orders",
"server/implementations/Catcrafts.Server-Rails",
@ -116,6 +116,7 @@ static Configuration* ServerCore(std::span<const std::string_view> args, Configu
"server/implementations/Catcrafts.Server-Eurc",
"server/implementations/Catcrafts.Server-Transfer",
"server/implementations/Catcrafts.Server-Bunq",
"server/implementations/Catcrafts.Server-CallbackShadow",
"server/implementations/Catcrafts.Server-Shipping",
"server/implementations/Catcrafts.Server-Mail",
"server/implementations/Catcrafts.Server-Financials",
@ -179,7 +180,33 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
.args = netArgs,
});
Configuration* core = ServerCore(args, network);
// 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.
//
// 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
// read, and moving it forward is a change to this line.
//
// Its args are this build's own minus `--product=`: Nostro reads that
// flag too, and `server` is no product of its.
std::vector<std::string> moneyArgs;
for (std::string_view a : args) {
if (!a.starts_with("--product=")) moneyArgs.emplace_back(a);
}
moneyArgs.emplace_back("--product=money");
moneyArgs.emplace_back("--banks=bunq");
Configuration* money = GitProject({
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Nostro.git",
.commit = "5d02cc6b96d43092204e8c32fb46bc0e98192945" },
.args = moneyArgs,
});
Configuration* core = ServerCore(args, network, money);
Configuration* shared = SharedLibrary(args);
Configuration cfg;
@ -236,6 +263,7 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
cfg.AddTest("ShouldIssueEurcAddresses").Dependencies({ core, shared });
cfg.AddTest("ShouldMatchBankTransfers").Dependencies({ core, shared });
cfg.AddTest("ShouldParseBunqPayments").Dependencies({ core, shared });
cfg.AddTest("ShouldCompareCallbackReaders").Dependencies({ core, shared });
// ── black-box suites (the tools/e2e.sh port) ──────────────────
// Each spawns the REAL binary — depending on &cfg is what builds it
@ -284,6 +312,16 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
.Dependencies({ &cfg, shared, network }).Args({ serverBin })
.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.
cfg.AddTest("ShouldReceiveBankCallbacks", harness)
.Dependencies({ &cfg, shared, network }).Args({ serverBin })
.Timeout(std::chrono::seconds(180));
// ── live-provider suite ───────────────────────────────────────
// The EURC rail settling an actual on-chain transfer on a testnet: a
// MANDATORY deploy gate in CI (the workflow supplies