commit 33961b8399dde8a021e0a1eb849f685e7ffd9963
parent 9ca55a895159377e8a0f9f1069599a5bc5c0c019
Author: Antoine A <>
Date: Tue, 4 Feb 2025 16:53:11 +0100
magnet-bank: fix magnet API
Diffstat:
6 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
@@ -304,9 +304,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
-version = "1.2.11"
+version = "1.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf"
+checksum = "755717a7de9ec452bf7f3f1a3099085deabd7f2962b861dae91ecd7a365903d2"
dependencies = [
"shlex",
]
diff --git a/common/taler-common/src/types/iban.rs b/common/taler-common/src/types/iban.rs
@@ -216,12 +216,12 @@ pub enum BicErrorKind {
BankCode,
#[error("invalid contry code")]
CountryCode,
- #[error("bad size expected or {MAX_BIC_SIZE} chars for {0}")]
+ #[error("bad size expected 8 or {MAX_BIC_SIZE} chars for {0}")]
Size(usize),
}
#[derive(Debug, thiserror::Error)]
-#[error("iban '{bic}' {kind}")]
+#[error("bic '{bic}' {kind}")]
pub struct ParseBicError {
bic: String,
pub kind: BicErrorKind,
diff --git a/common/taler-common/src/types/payto.rs b/common/taler-common/src/types/payto.rs
@@ -121,11 +121,11 @@ impl FromStr for PaytoURI {
}
}
-pub type IbanPayto = Payto<IbanBic>;
-pub type FullIbanPayto = FullPayto<IbanPayto>;
+pub type IbanPayto = Payto<BankID>;
+pub type FullIbanPayto = FullPayto<BankID>;
#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct IbanBic {
+pub struct BankID {
pub iban: IBAN,
pub bic: Option<BIC>,
}
@@ -133,7 +133,7 @@ pub struct IbanBic {
const IBAN: &str = "iban";
#[derive(Debug, thiserror::Error)]
-pub enum IbanBicErr {
+pub enum BankIDErr {
#[error("missing IBAN in path")]
MissingIban,
#[error(transparent)]
@@ -142,7 +142,7 @@ pub enum IbanBicErr {
BIC(#[from] ParseBicError),
}
-impl PaytoImpl for IbanBic {
+impl PaytoImpl for BankID {
fn as_payto(&self) -> PaytoURI {
PaytoURI::from_parts(IBAN, format_args!("/{}", self.iban))
}
@@ -156,15 +156,15 @@ impl PaytoImpl for IbanBic {
));
}
let Some(mut segments) = url.path_segments() else {
- return Err(PaytoErr::custom(IbanBicErr::MissingIban));
+ return Err(PaytoErr::custom(BankIDErr::MissingIban));
};
let Some(first) = segments.next() else {
- return Err(PaytoErr::custom(IbanBicErr::MissingIban));
+ return Err(PaytoErr::custom(BankIDErr::MissingIban));
};
let (iban, bic) = match segments.next() {
Some(second) => (
second.parse().map_err(PaytoErr::custom)?,
- Some(second.parse().map_err(PaytoErr::custom)?),
+ Some(first.parse().map_err(PaytoErr::custom)?),
),
None => (first.parse().map_err(PaytoErr::custom)?, None),
};
@@ -179,7 +179,7 @@ impl PaytoImpl for IBAN {
}
fn parse(raw: &PaytoURI) -> Result<Self, PaytoErr> {
- let payto = IbanBic::parse(raw)?;
+ let payto = BankID::parse(raw)?;
Ok(payto.iban)
}
}
diff --git a/taler-magnet-bank/src/dev.rs b/taler-magnet-bank/src/dev.rs
@@ -85,7 +85,9 @@ pub async fn dev(cfg: Config, cmd: DevCmd) -> anyhow::Result<()> {
// Register incoming
let mut next = None;
loop {
- let page = client.page_tx(dir, 5, account.bban(), &next, &None).await?;
+ let page = client
+ .page_tx(dir, 100, account.bban(), &next, &None)
+ .await?;
next = page.next;
for item in page.list {
let tx = extract_tx_info(item.tx);
@@ -118,8 +120,7 @@ pub async fn dev(cfg: Config, cmd: DevCmd) -> anyhow::Result<()> {
&creditor.name,
creditor.bban(),
)
- .await?
- .tx;
+ .await?;
client
.sign_tx(
&keys.signing_key,
diff --git a/taler-magnet-bank/src/magnet.rs b/taler-magnet-bank/src/magnet.rs
@@ -188,8 +188,6 @@ pub enum Direction {
#[derive(Debug, Deserialize)]
pub struct TxInfo {
- #[serde(flatten)]
- pub tx: Transaction,
#[serde(rename = "alairas1idopont")]
pub first_signature: Option<Timestamp>,
#[serde(rename = "alairas2idopont")]
@@ -202,6 +200,31 @@ pub struct TxInfo {
pub partial_execution: bool,
#[serde(rename = "sorbaallitas")]
pub queued: bool,
+ #[serde(rename = "kod")]
+ pub code: u64,
+ #[serde(rename = "bankszamla")]
+ pub bank_account: Account,
+ #[serde(rename = "deviza")]
+ pub currency: Currency,
+ #[serde(rename = "osszegSigned")]
+ pub amount: f64,
+ #[serde(rename = "kozlemeny")]
+ pub subject: String,
+ #[serde(rename = "statusz")]
+ pub status: TxStatus,
+ #[serde(rename = "tranzakcioAltipus")]
+ pub kind: Option<String>,
+ #[serde(rename = "eredetiErteknap")]
+ pub tx_date: jiff::civil::Date,
+ #[serde(rename = "erteknap")]
+ pub value_date: jiff::civil::Date,
+ #[serde(rename = "eszamla")]
+ pub counter_account: String,
+ #[serde(rename = "epartner")]
+ pub counter_name: String,
+ #[serde(rename = "tranzakcioTipus")]
+ pub ty: Option<String>,
+ pub eam: Option<u64>,
}
#[derive(Debug, Deserialize)]
diff --git a/taler-magnet-bank/src/worker.rs b/taler-magnet-bank/src/worker.rs
@@ -171,8 +171,7 @@ impl Worker<'_> {
&tx.creditor.name,
tx.creditor.bban(),
)
- .await?
- .tx;
+ .await?;
debug!("created tx {}", info.code);
// TODO handle API errors gracefully
fail_point("submit-success");