fix 1.23.3: ladder requires wallet-cli; settle for coins so pay can run

Root cause of stale intro payments: koopa max-ladder minted but accept-uri
failed with taler-wallet-cli not found (SKIP_ACCEPT ×16). Fail early without
CLI/helper; after bank transfer_done keep polling + run-pending for available
coins; pay wait 180s; host-agent max-ladder sets WALLET_CLI PATH.
This commit is contained in:
Hernâni Marques 2026-07-19 15:19:25 +02:00
parent bf04f90538
commit a103eeab9d
No known key found for this signature in database
6 changed files with 51 additions and 11 deletions

View file

@ -88,7 +88,7 @@ elapsed_ms() {
# optional seed for reproducible max-search (empty = time-based)
: "${LADDER_MAX_SEED:=}"
# After withdraw, wait for spendable available>0 before pay (secs total; shows countdown)
: "${LADDER_PAY_WAIT_AVAILABLE_S:=90}"
: "${LADDER_PAY_WAIT_AVAILABLE_S:=180}"
# Historic libeufin-ish absolute ceiling used as default LADDER_MAX_AMOUNT on GOA
LADDER_ABS_CEILING="4503599627370496"
@ -99,8 +99,20 @@ if [ -z "${CLI_JS}" ] || [ ! -f "${CLI_JS}" ]; then
CLI_JS=$(find_wallet_cli 2>/dev/null || true)
fi
if [ -z "${CLI_JS}" ] || [ ! -f "${CLI_JS}" ]; then
# allow PATH wrapper as last resort (wcli falls back to taler-wallet-cli)
CLI_JS=""
# PATH wrapper last resort
if command -v taler-wallet-cli >/dev/null 2>&1; then
CLI_JS=""
else
err prereq "taler-wallet-cli not found" \
"problem: no CLI_JS / WALLET_CLI .mjs and taler-wallet-cli not on PATH — accept-uri/pay cannot run (payments stay stale). Install wallet-cli (e.g. ~/.local/bin/taler-wallet-cli.mjs) + taler-helper-sqlite3; set WALLET_CLI= in ~/.config/taler-monitoring/env"
exit 1
fi
fi
# helper is required for real wallet DB (otherwise accept "works" empty / no coins)
if ! command -v taler-helper-sqlite3 >/dev/null 2>&1; then
err prereq "taler-helper-sqlite3 not on PATH" \
"problem: wallet-cli needs taler-helper-sqlite3 for sqlite backend — put it on PATH next to wallet-cli"
exit 1
fi
CUR="${EXPECT_CURRENCY:-GOA}"
@ -522,9 +534,16 @@ else
info "explorer secret" "resolved via EXP_PW / EXP_PW_FILE / stage SSH / koopa"
fi
if [ -n "${CLI_JS:-}" ] && [ -f "${CLI_JS}" ]; then
info "wallet-cli" "$CLI_JS"
ok "wallet-cli" "$CLI_JS"
else
info "wallet-cli" "PATH taler-wallet-cli ($(command -v taler-wallet-cli 2>/dev/null || echo missing))"
ok "wallet-cli" "PATH $(command -v taler-wallet-cli)"
fi
ok "wallet-helper" "$(command -v taler-helper-sqlite3)"
# prove wcli can start (avoids minting 32 probes then SKIP_ACCEPT command-not-found)
if ! wcli balance >"$SCRATCH/wcli-smoke.out" 2>&1; then
err prereq "wallet-cli smoke failed" \
"problem: wcli balance failed — fix CLI_JS/PATH/helper. detail: $(tr '\n' ' ' <"$SCRATCH/wcli-smoke.out" | head -c 240)"
exit 1
fi
# --- auto-account ---
@ -910,10 +929,13 @@ else:
fi
ok "confirm $AMT ${ms_confirm}ms (client, on selected)"
# settle: poll wallet balance + bank transfer_done only — never run-until-done
# settle: poll wallet balance + bank transfer_done — never run-until-done.
# Prefer real coin delta (status OK). If bank transfer_done first, keep polling
# briefly for available coins (OK) before accepting OK_BANK (pay needs available).
t0=$(now_ms)
settled=0
xfer="?"
bank_done=0
if [ "$IS_ZERO" = "1" ]; then
settled=1
note="zero-amount: no coin delta expected"
@ -931,13 +953,23 @@ sys.exit(0 if Decimal(sys.argv[1]) > Decimal(sys.argv[2]) else 1)
fi
xfer=$(curl -sS -m 10 "${BANK}/taler-integration/withdrawal-operation/${WID}" \
| python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("transfer_done"), d.get("status"))' 2>/dev/null || echo "?")
# bank done is enough to leave settle without hanging on wallet
if echo "$xfer" | grep -qi True; then
note="bank transfer_done (no run-until-done) avail=${after} $xfer"
break
bank_done=1
# nudge wallet to pick up wire (bounded; not run-until-done)
wcli transactions >"$SCRATCH/tx-settle-$tag.out" 2>&1 || true
if command -v timeout >/dev/null 2>&1 || command -v gtimeout >/dev/null 2>&1; then
_to=$(command -v gtimeout 2>/dev/null || command -v timeout)
"$_to" 8 wcli advanced run-pending >"$SCRATCH/run-pending-settle.out" 2>&1 || true
fi
# after bank done, still prefer coins; allow remaining rounds for available
note="bank transfer_done waiting coins avail=${after} $xfer"
fi
sleep "$LADDER_SETTLE_SLEEP"
done
# If bank done but still no coin delta after all rounds, OK_BANK (pay-wait may finish)
if [ "$settled" != "1" ] && [ "$bank_done" = "1" ]; then
note="bank transfer_done avail=$(wallet_avail) $xfer (no run-until-done)"
fi
fi
ms_settle=$(elapsed_ms "$t0")
after=$(wallet_avail)