commit 9d00fd837855f3480f169f7361f484e5038bc1d6
parent 471390e2b829f9c5ff229d994d789c89bdc802d3
Author: Antoine A <>
Date: Mon, 21 Mar 2022 17:49:42 +0100
remove all occurrence of withdraw and deposit
Diffstat:
22 files changed, 112 insertions(+), 118 deletions(-)
diff --git a/btc-wire/README.md b/btc-wire/README.md
@@ -3,7 +3,7 @@
btc-wire is taler wire adapter for
[bitcoincore](https://bitcoincore.org/en/about/) node
-## Deposit metadata format
+## Credit metadata format
Starting from a bitcoin payto URI you will have to generate fake segwit
addresses to encode the reserve public key as metadata into a common bitcoin
diff --git a/btc-wire/src/bin/btc-wire-utils.rs b/btc-wire/src/bin/btc-wire-utils.rs
@@ -40,7 +40,7 @@ struct Args {
#[derive(clap::Subcommand, Debug)]
enum Cmd {
- /// Send taler deposit transactions
+ /// Perform wire credit transactions
Transfer {
#[clap(short, long, default_value_t = String::from("client"))]
/// sender wallet
diff --git a/btc-wire/src/loops/worker.rs b/btc-wire/src/loops/worker.rs
@@ -34,7 +34,7 @@ use common::{
postgres,
reconnect::AutoReconnectDb,
sql::{sql_array, sql_url},
- status::{BounceStatus, WithdrawStatus},
+ status::{BounceStatus, DebitStatus},
};
use postgres::{fallible_iterator::FallibleIterator, Client};
@@ -101,8 +101,8 @@ pub fn worker(mut rpc: AutoRpcWallet, mut db: AutoReconnectDb, state: &WireState
if let Some(stuck) = sync_chain(rpc, db, state, &mut status)? {
// As we are now in sync with the blockchain if a transaction has Requested status it have not been sent
- // Send requested withdraws
- while withdraw(db, rpc, state)? {}
+ // Send requested debits
+ while debit(db, rpc, state)? {}
// Bump stuck transactions
for id in stuck {
@@ -239,13 +239,13 @@ fn sync_chain_removed(
db: &mut Client,
min_confirmations: i32,
) -> LoopResult<bool> {
- // Removed transactions are correctness issues in only two cases:
- // - An incoming valid transaction considered confirmed in the database
- // - An incoming invalid transactions already bounced
+ // A removed incoming transaction is a correctness issues in only two cases:
+ // - it is a confirmed credit registered in the database
+ // - it is an invalid transactions already bounced
// Those two cases can compromise bitcoin backing
// Removed outgoing transactions will be retried automatically by the node
- let mut blocking_deposit = Vec::new();
+ let mut blocking_debit = Vec::new();
let mut blocking_bounce = Vec::new();
// Only keep incoming transaction that are not reconfirmed
@@ -259,13 +259,13 @@ fn sync_chain_removed(
}) {
match rpc.get_tx_segwit_key(id) {
Ok((full, key)) => {
- // Deposit are only problematic if not reconfirmed and stored in the database
+ // Credits are only problematic if not reconfirmed and stored in the database
if db
.query_opt("SELECT 1 FROM tx_in WHERE reserve_pub=$1", &[&key.as_ref()])?
.is_some()
{
let debit_addr = sender_address(rpc, &full)?;
- blocking_deposit.push((key, id, debit_addr));
+ blocking_debit.push((key, id, debit_addr));
}
}
Err(err) => match err {
@@ -286,12 +286,12 @@ fn sync_chain_removed(
}
}
- if !blocking_bounce.is_empty() || !blocking_deposit.is_empty() {
+ if !blocking_bounce.is_empty() || !blocking_debit.is_empty() {
let mut buf = "The following transaction have been removed from the blockchain, bitcoin backing is compromised until the transaction reappear:".to_string();
- for (key, id, addr) in blocking_deposit {
+ for (key, id, addr) in blocking_debit {
write!(
&mut buf,
- "\n\tdeposit {} in {} from {}",
+ "\n\tcredit {} in {} from {}",
base32(&key),
id,
addr
@@ -349,8 +349,8 @@ fn sync_chain_incoming_confirmed(
Ok(())
}
-/// Sync database with an outgoing withdraw transaction, return true if stuck
-fn sync_chain_withdraw(
+/// Sync database with a debit transaction, return true if stuck
+fn sync_chain_debit(
id: &Txid,
full: &Transaction,
wtid: &[u8; 32],
@@ -367,7 +367,7 @@ fn sync_chain_withdraw(
// Handle conflicting tx
let nb_row = db.execute(
"UPDATE tx_out SET status=$1, txid=NULL where txid=$2",
- &[&(WithdrawStatus::Requested as i16), &id.as_ref()],
+ &[&(DebitStatus::Requested as i16), &id.as_ref()],
)?;
if nb_row > 0 {
warn!(
@@ -388,12 +388,12 @@ fn sync_chain_withdraw(
// If already in database, sync status
let row_id: i32 = row.get(0);
let status: i16 = row.get(1);
- match WithdrawStatus::try_from(status as u8).unwrap() {
- WithdrawStatus::Requested => {
+ match DebitStatus::try_from(status as u8).unwrap() {
+ DebitStatus::Requested => {
let nb_row = db.execute(
"UPDATE tx_out SET status=$1, txid=$2 WHERE id=$3 AND status=$4",
&[
- &(WithdrawStatus::Sent as i16),
+ &(DebitStatus::Sent as i16),
&id.as_ref(),
&row_id,
&status,
@@ -409,7 +409,7 @@ fn sync_chain_withdraw(
);
}
}
- WithdrawStatus::Sent => {
+ DebitStatus::Sent => {
if let Some(txid) = full.replaces_txid {
let stored_id = sql_txid(&row, 2);
if txid == stored_id {
@@ -435,7 +435,7 @@ fn sync_chain_withdraw(
let date = SystemTime::UNIX_EPOCH + Duration::from_secs(full.time);
let nb = db.execute(
"INSERT INTO tx_out (_date, amount, wtid, debit_acc, credit_acc, exchange_url, status, txid, request_uid) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (wtid) DO NOTHING",
- &[&date, &amount.to_string(), &wtid.as_ref(), &btc_payto_url(&debit_addr).as_ref(), &btc_payto_url(credit_addr).as_ref(), &state.base_url.as_ref(), &(WithdrawStatus::Sent as i16), &id.as_ref(), &None::<&[u8]>],
+ &[&date, &amount.to_string(), &wtid.as_ref(), &btc_payto_url(&debit_addr).as_ref(), &btc_payto_url(credit_addr).as_ref(), &state.base_url.as_ref(), &(DebitStatus::Sent as i16), &id.as_ref(), &None::<&[u8]>],
)?;
if nb > 0 {
warn!(
@@ -534,8 +534,8 @@ fn sync_chain_outgoing(
.map(|(full, bytes)| (full, OutMetadata::decode(&bytes)))
{
Ok((full, Ok(info))) => match info {
- OutMetadata::Withdraw { wtid, .. } => {
- return sync_chain_withdraw(id, &full, &wtid, rpc, db, confirmations, state);
+ OutMetadata::Debit { wtid, .. } => {
+ return sync_chain_debit(id, &full, &wtid, rpc, db, confirmations, state);
}
OutMetadata::Bounce { bounced } => {
sync_chain_bounce(id, &Txid::from_inner(bounced), db, confirmations)?
@@ -550,12 +550,12 @@ fn sync_chain_outgoing(
Ok(false)
}
-/// Send a withdraw transaction on the blockchain, return false if no more requested transactions are found
-fn withdraw(db: &mut Client, rpc: &mut Rpc, state: &WireState) -> LoopResult<bool> {
+/// Send a debit transaction on the blockchain, return false if no more requested transactions are found
+fn debit(db: &mut Client, rpc: &mut Rpc, state: &WireState) -> LoopResult<bool> {
// We rely on the advisory lock to ensure we are the only one sending transactions
let row = db.query_opt(
"SELECT id, amount, wtid, credit_acc, exchange_url FROM tx_out WHERE status=$1 ORDER BY _date LIMIT 1",
- &[&(WithdrawStatus::Requested as i16)],
+ &[&(DebitStatus::Requested as i16)],
)?;
if let Some(row) = &row {
let id: i32 = row.get(0);
@@ -563,13 +563,13 @@ fn withdraw(db: &mut Client, rpc: &mut Rpc, state: &WireState) -> LoopResult<boo
let wtid: [u8; 32] = sql_array(row, 2);
let addr = sql_addr(row, 3);
let url = sql_url(row, 4);
- let metadata = OutMetadata::Withdraw { wtid, url };
+ let metadata = OutMetadata::Debit { wtid, url };
let tx_id = rpc.send(&addr, &amount, Some(&metadata.encode()), false)?;
- fail_point("(injected) fail withdraw", 0.3)?;
+ fail_point("(injected) fail debit", 0.3)?;
db.execute(
"UPDATE tx_out SET status=$1, txid=$2 WHERE id=$3",
- &[&(WithdrawStatus::Sent as i16), &tx_id.as_ref(), &id],
+ &[&(DebitStatus::Sent as i16), &tx_id.as_ref(), &id],
)?;
let amount = btc_to_taler(&amount.to_signed().unwrap(), state.currency);
info!(">> {} {} in {} to {}", amount, base32(&wtid), tx_id, addr);
diff --git a/common/src/metadata.rs b/common/src/metadata.rs
@@ -31,7 +31,7 @@ pub enum DecodeErr {
/// Encoded metadata for outgoing transaction
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OutMetadata {
- Withdraw { wtid: [u8; 32], url: Url },
+ Debit { wtid: [u8; 32], url: Url },
Bounce { bounced: [u8; 32] },
}
@@ -42,7 +42,7 @@ impl OutMetadata {
pub fn encode(&self) -> Vec<u8> {
let mut buffer = Vec::new();
match self {
- OutMetadata::Withdraw { wtid, url } => {
+ OutMetadata::Debit { wtid, url } => {
buffer.push(if url.scheme() == "http" { 1 } else { 0 });
buffer.extend_from_slice(wtid);
let parts = format!("{}{}", url.domain().unwrap_or(""), url.path());
@@ -72,7 +72,7 @@ impl OutMetadata {
uri_pack::unpack_uri(&bytes[33..])?,
);
let url = Url::parse(&packed).unwrap();
- Ok(OutMetadata::Withdraw {
+ Ok(OutMetadata::Debit {
wtid: bytes[1..33].try_into().unwrap(),
url,
})
@@ -93,14 +93,14 @@ impl OutMetadata {
/// Encoded metadata for incoming transaction
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum InMetadata {
- Deposit { reserve_pub: [u8; 32] },
+ Credit { reserve_pub: [u8; 32] },
}
impl InMetadata {
pub fn encode(&self) -> Vec<u8> {
let mut buffer = Vec::new();
match self {
- InMetadata::Deposit { reserve_pub } => {
+ InMetadata::Credit { reserve_pub } => {
buffer.push(0);
buffer.extend_from_slice(reserve_pub);
}
@@ -117,7 +117,7 @@ impl InMetadata {
if bytes.len() < 33 {
return Err(DecodeErr::UnexpectedEOF);
}
- Ok(InMetadata::Deposit {
+ Ok(InMetadata::Credit {
reserve_pub: bytes[1..33].try_into().unwrap(),
})
}
@@ -137,9 +137,9 @@ mod test {
};
#[test]
- fn decode_encode_deposit() {
+ fn decode_encode_credit() {
for _ in 0..4 {
- let metadata = InMetadata::Deposit {
+ let metadata = InMetadata::Credit {
reserve_pub: rand_slice(),
};
let encoded = metadata.encode();
@@ -149,7 +149,7 @@ mod test {
}
#[test]
- fn decode_encode_withdraw() {
+ fn decode_encode_debit() {
let urls = [
"https://git.taler.net/",
"https://git.taler.net/depolymerization.git/",
@@ -159,7 +159,7 @@ mod test {
for url in urls {
let wtid = rand_slice();
let url = Url::parse(url).unwrap();
- let metadata = OutMetadata::Withdraw { wtid, url };
+ let metadata = OutMetadata::Debit { wtid, url };
let encoded = metadata.encode();
let decoded = OutMetadata::decode(&encoded).unwrap();
assert_eq!(decoded, metadata);
diff --git a/common/src/status.rs b/common/src/status.rs
@@ -15,27 +15,27 @@
*/
//! Transactions status in database
-/// Withdraw transaction status
+/// Debit transaction status
///
/// -> Requested API request
/// Requested -> Sent Announced to the bitcoin network
/// Sent -> Requested Conflicting transaction (reorg)
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum WithdrawStatus {
- /// Withdraw have been requested (default)
+pub enum DebitStatus {
+ /// Debit have been requested (default)
Requested = 0,
- /// Withdraw have been announced to the bitcoin network
+ /// Debit have been announced to the bitcoin network
Sent = 1,
}
-impl TryFrom<u8> for WithdrawStatus {
+impl TryFrom<u8> for DebitStatus {
type Error = ();
fn try_from(v: u8) -> Result<Self, Self::Error> {
match v {
- x if x == WithdrawStatus::Requested as u8 => Ok(WithdrawStatus::Requested),
- x if x == WithdrawStatus::Sent as u8 => Ok(WithdrawStatus::Sent),
+ x if x == DebitStatus::Requested as u8 => Ok(DebitStatus::Requested),
+ x if x == DebitStatus::Sent as u8 => Ok(DebitStatus::Sent),
_ => Err(()),
}
}
@@ -43,7 +43,7 @@ impl TryFrom<u8> for WithdrawStatus {
/// Bounce transaction status
///
-/// -> Requested Deposit in wrong format
+/// -> Requested Credit in wrong format
/// Requested -> Ignored Insufficient found
/// Requested -> Sent Announced to the bitcoin network
/// Sent -> Requested Conflicting transaction (reorg)
diff --git a/docs/report.tex b/docs/report.tex
@@ -98,7 +98,7 @@ Some properties of blockchain-based cryptocurrencies are problematic for their u
\subsection{Solving chain reorganisation}
-Taler expects deposit transactions to be final. If a deposit transaction disappears from the blockchain, an irrevocable withdrawal transaction would no longer be backed by credit. This problem is well known and already mentioned in the Bitcoin white paper \cite{nakamoto2008bitcoin}. The solution is to wait until a block has a certain amount of blocks linked to it, before considering its transactions final.
+Taler expects credits to be final. If a credit disappears from the blockchain, an irrevocable debit would no longer be backed by credit. This problem is well known and already mentioned in the Bitcoin white paper \cite{nakamoto2008bitcoin}. The solution is to wait until a block has a certain amount of blocks linked to it, before considering its transactions final.
\begin{figure}[H]
\begin{center}
@@ -311,8 +311,8 @@ expensive and limited. Therefore we want our metadata to be as small as possible
Transactions metadata are composed of three parts:
\begin{itemize}
\item Version and identity metadata ($\sim$ 1B)
- \item Reserve public key or withdraw id (32B)
- \item Base uri (withdraw only, variable)
+ \item Reserve public key or wire transfer id (32B)
+ \item Base uri (debit only, variable)
\end{itemize}
The only variable and so problematic part is the base url. Those url have some
diff --git a/eth-wire/README.md b/eth-wire/README.md
@@ -3,7 +3,7 @@
eth-wire is taler wire adapter for [go-ethereum](https://geth.ethereum.org/)
node
-## Deposit metadata format
+## Credit metadata format
TODO
diff --git a/eth-wire/src/bin/eth-wire-utils.rs b/eth-wire/src/bin/eth-wire-utils.rs
@@ -60,8 +60,8 @@ struct TransactionCmd {
enum Cmd {
/// Send common ethereum transactions
Send(TransactionCmd),
- /// Send taler deposit transactions
- Deposit(TransactionCmd),
+ /// Send taler credit transactions
+ Credit(TransactionCmd),
/// Mine pending transactions and more blocks
Mine {
/// receiver wallet
@@ -110,7 +110,7 @@ fn main() {
let mut rpc = Rpc::new(ipc_path).unwrap();
let passwd = password();
match args.cmd {
- Cmd::Deposit(TransactionCmd {
+ Cmd::Credit(TransactionCmd {
from,
to,
fmt,
@@ -123,7 +123,7 @@ fn main() {
let amount =
Amount::from_str(&format!("{}:{}{}", currency.to_str(), fmt, amount)).unwrap();
let value = taler_to_eth(&amount, currency).unwrap();
- rpc.deposit(from, to, value, rand_slice()).unwrap();
+ rpc.credit(from, to, value, rand_slice()).unwrap();
}
}
Cmd::Send(TransactionCmd {
diff --git a/eth-wire/src/lib.rs b/eth-wire/src/lib.rs
@@ -42,15 +42,15 @@ pub mod taler_util;
/// An extended geth JSON-RPC api client who can send and retrieve metadata with their transaction
pub trait RpcExtended: RpcClient {
- /// Perform a Taler deposit
- fn deposit(
+ /// Perform a wire credit
+ fn credit(
&mut self,
from: Address,
to: Address,
value: U256,
reserve_pub: [u8; 32],
) -> rpc::Result<H256> {
- let metadata = InMetadata::Deposit { reserve_pub };
+ let metadata = InMetadata::Credit { reserve_pub };
self.send_transaction(&rpc::TransactionRequest {
from,
to,
@@ -61,8 +61,8 @@ pub trait RpcExtended: RpcClient {
})
}
- /// Perform a Taler withdraw
- fn withdraw(
+ /// Perform a wire debit
+ fn debit(
&mut self,
from: Address,
to: Address,
@@ -70,7 +70,7 @@ pub trait RpcExtended: RpcClient {
wtid: [u8; 32],
url: Url,
) -> rpc::Result<H256> {
- let metadata = OutMetadata::Withdraw { wtid, url };
+ let metadata = OutMetadata::Debit { wtid, url };
self.send_transaction(&rpc::TransactionRequest {
from,
to,
diff --git a/eth-wire/src/loops/worker.rs b/eth-wire/src/loops/worker.rs
@@ -22,7 +22,7 @@ use common::{
postgres::{fallible_iterator::FallibleIterator, Client},
reconnect::AutoReconnectDb,
sql::{sql_array, sql_url},
- status::{BounceStatus, WithdrawStatus},
+ status::{BounceStatus, DebitStatus},
};
use eth_wire::{
rpc::{self, AutoRpcWallet, Rpc, RpcClient, Transaction, TransactionRequest},
@@ -94,8 +94,8 @@ pub fn worker(mut rpc: AutoRpcWallet, mut db: AutoReconnectDb, state: &WireState
if sync_chain(rpc, db, state, &mut status)? {
// As we are now in sync with the blockchain if a transaction has Requested status it have not been sent
- // Send requested withdraws
- while withdraw(db, rpc, state)? {}
+ // Send requested debits
+ while debit(db, rpc, state)? {}
// Bump stuck transactions
while bump(db, rpc, state)? {}
@@ -138,13 +138,7 @@ fn sync_chain(
let list = rpc.list_since_sync(&state.address, sync_state, conf_delay)?;
// Check if a confirmed incoming transaction have been removed by a blockchain reorganisation
- let new_status = sync_chain_removed(
- &list.txs,
- &list.removed,
- db,
- &state.address,
- conf_delay,
- )?;
+ let new_status = sync_chain_removed(&list.txs, &list.removed, db, &state.address, conf_delay)?;
// Sync status with database
if *status != new_status {
@@ -188,13 +182,13 @@ fn sync_chain_removed(
addr: &Address,
min_confirmation: u32,
) -> LoopResult<bool> {
- // Removed transactions are correctness issues in only two cases:
- // - An incoming valid transaction considered confirmed in the database
- // - An incoming invalid transactions already bounced
- // Those two cases can compromise ethereum backing
+ // A removed incoming transaction is a correctness issues in only two cases:
+ // - it is a confirmed credit registered in the database
+ // - it is an invalid transactions already bounced
+ // Those two cases can compromise bitcoin backing
// Removed outgoing transactions will be retried automatically by the node
- let mut blocking_deposit = Vec::new();
+ let mut blocking_credit = Vec::new();
let mut blocking_bounce = Vec::new();
// Only keep incoming transaction that are not reconfirmed
@@ -208,8 +202,8 @@ fn sync_chain_removed(
}) {
match InMetadata::decode(&tx.input) {
Ok(metadata) => match metadata {
- InMetadata::Deposit { reserve_pub } => {
- // Deposit are only problematic if not reconfirmed and stored in the database
+ InMetadata::Credit { reserve_pub } => {
+ // Credits are only problematic if not reconfirmed and stored in the database
if db
.query_opt(
"SELECT 1 FROM tx_in WHERE reserve_pub=$1",
@@ -217,7 +211,7 @@ fn sync_chain_removed(
)?
.is_some()
{
- blocking_deposit.push((reserve_pub, tx.hash, tx.from.unwrap()));
+ blocking_credit.push((reserve_pub, tx.hash, tx.from.unwrap()));
}
}
},
@@ -236,12 +230,12 @@ fn sync_chain_removed(
}
}
- if !blocking_bounce.is_empty() || !blocking_deposit.is_empty() {
+ if !blocking_bounce.is_empty() || !blocking_credit.is_empty() {
let mut buf = "The following transaction have been removed from the blockchain, ethereum backing is compromised until the transaction reappear:".to_string();
- for (key, id, addr) in blocking_deposit {
+ for (key, id, addr) in blocking_credit {
write!(
&mut buf,
- "\n\tdeposit {} in {} from {}",
+ "\n\tcredit {} in {} from {}",
base32(&key),
hex::encode(id),
hex::encode(addr)
@@ -272,7 +266,7 @@ fn sync_chain_incoming_confirmed(
) -> Result<(), LoopError> {
match InMetadata::decode(&tx.input) {
Ok(metadata) => match metadata {
- InMetadata::Deposit { reserve_pub } => {
+ InMetadata::Credit { reserve_pub } => {
let date = SystemTime::now();
let amount = eth_to_taler(&tx.value, state.currency);
let credit_addr = tx.from.expect("Not coinbase");
@@ -306,7 +300,7 @@ fn sync_chain_outgoing(tx: &SyncTransaction, db: &mut Client, state: &WireState)
let SyncTransaction { tx, confirmations } = tx;
match OutMetadata::decode(&tx.input) {
Ok(metadata) => match metadata {
- OutMetadata::Withdraw { wtid, .. } => {
+ OutMetadata::Debit { wtid, .. } => {
let amount = eth_to_taler(&tx.value, state.currency);
let credit_addr = tx.to.unwrap();
// Get previous out tx
@@ -320,21 +314,21 @@ fn sync_chain_outgoing(tx: &SyncTransaction, db: &mut Client, state: &WireState)
let status: i16 = row.get(1);
let sent: Option<SystemTime> = row.get(2);
- let expected_status = WithdrawStatus::Sent as i16;
+ let expected_status = DebitStatus::Sent as i16;
let expected_send = sent.filter(|_| *confirmations == 0);
if status != expected_status || sent != expected_send {
let nb_row = db.execute(
"UPDATE tx_out SET status=$1, txid=$2, sent=NULL WHERE id=$3 AND status=$4",
&[
- &(WithdrawStatus::Sent as i16),
+ &(DebitStatus::Sent as i16),
&tx.hash.as_ref(),
&row_id,
&status,
],
)?;
if nb_row > 0 {
- match WithdrawStatus::try_from(status as u8).unwrap() {
- WithdrawStatus::Requested => {
+ match DebitStatus::try_from(status as u8).unwrap() {
+ DebitStatus::Requested => {
warn!(
">> (recovered) {} {} in {} to {}",
amount,
@@ -343,7 +337,7 @@ fn sync_chain_outgoing(tx: &SyncTransaction, db: &mut Client, state: &WireState)
hex::encode(credit_addr)
);
}
- WithdrawStatus::Sent => { /* Status is correct */ }
+ DebitStatus::Sent => { /* Status is correct */ }
}
}
}
@@ -352,7 +346,7 @@ fn sync_chain_outgoing(tx: &SyncTransaction, db: &mut Client, state: &WireState)
let date = SystemTime::now();
let nb = db.execute(
"INSERT INTO tx_out (_date, amount, wtid, debit_acc, credit_acc, exchange_url, status, txid, request_uid) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (wtid) DO NOTHING",
- &[&date, &amount.to_string(), &wtid.as_ref(), ð_payto_url(&state.address).as_ref(), ð_payto_url(&credit_addr).as_ref(), &state.base_url.as_ref(), &(WithdrawStatus::Sent as i16), &tx.hash.as_ref(), &None::<&[u8]>],
+ &[&date, &amount.to_string(), &wtid.as_ref(), ð_payto_url(&state.address).as_ref(), ð_payto_url(&credit_addr).as_ref(), &state.base_url.as_ref(), &(DebitStatus::Sent as i16), &tx.hash.as_ref(), &None::<&[u8]>],
)?;
if nb > 0 {
warn!(
@@ -415,12 +409,12 @@ fn sync_chain_outgoing(tx: &SyncTransaction, db: &mut Client, state: &WireState)
Ok(())
}
-/// Send a withdraw transaction on the blockchain, return false if no more requested transactions are found
-fn withdraw(db: &mut Client, rpc: &mut Rpc, state: &WireState) -> LoopResult<bool> {
+/// Send a debit transaction on the blockchain, return false if no more requested transactions are found
+fn debit(db: &mut Client, rpc: &mut Rpc, state: &WireState) -> LoopResult<bool> {
// We rely on the advisory lock to ensure we are the only one sending transactions
let row = db.query_opt(
"SELECT id, amount, wtid, credit_acc, exchange_url FROM tx_out WHERE status=$1 ORDER BY _date LIMIT 1",
-&[&(WithdrawStatus::Requested as i16)],
+&[&(DebitStatus::Requested as i16)],
)?;
if let Some(row) = &row {
let id: i32 = row.get(0);
@@ -428,11 +422,11 @@ fn withdraw(db: &mut Client, rpc: &mut Rpc, state: &WireState) -> LoopResult<boo
let wtid: [u8; 32] = sql_array(row, 2);
let addr = sql_addr(row, 3);
let url = sql_url(row, 4);
- let tx_id = rpc.withdraw(state.address, addr, amount, wtid, url)?;
- fail_point("(injected) fail withdraw", 0.3)?;
+ let tx_id = rpc.debit(state.address, addr, amount, wtid, url)?;
+ fail_point("(injected) fail debit", 0.3)?;
db.execute(
"UPDATE tx_out SET status=$1, txid=$2, sent=now() WHERE id=$3",
- &[&(WithdrawStatus::Sent as i16), &tx_id.as_ref(), &id],
+ &[&(DebitStatus::Sent as i16), &tx_id.as_ref(), &id],
)?;
let amount = eth_to_taler(&amount, state.currency);
info!(
@@ -452,7 +446,7 @@ fn bump(db: &mut Client, rpc: &mut Rpc, state: &WireState) -> LoopResult<bool> {
// We rely on the advisory lock to ensure we are the only one sending transactions
let row = db.query_opt(
"SELECT id, txid FROM tx_out WHERE status=$1 AND EXTRACT(EPOCH FROM (now() - sent)) > $2 ORDER BY _date LIMIT 1",
- &[&(WithdrawStatus::Sent as i16), &(delay as f64)],
+ &[&(DebitStatus::Sent as i16), &(delay as f64)],
)?;
if let Some(row) = &row {
let id: i32 = row.get(0);
diff --git a/instrumentation/src/btc.rs b/instrumentation/src/btc.rs
@@ -115,7 +115,7 @@ pub fn btc_test(config: Option<&Path>, base_url: &str) {
println!("Send transaction");
let reserve_pub_key = rand_slice();
- let deposit_id = client_rpc
+ let credit_id = client_rpc
.send_segwit_key(&wire_addr, &test_amount, &reserve_pub_key)
.unwrap();
let bounce_min_id = client_rpc
@@ -129,7 +129,7 @@ pub fn btc_test(config: Option<&Path>, base_url: &str) {
.unwrap();
let client_sent_amount_cost =
test_amount + min_send_amount * 2 + min_bounce_amount + min_send_amount + test_amount;
- let client_sent_fees_cost: Amount = [deposit_id, bounce_min_id, send_min_id, bounce_id]
+ let client_sent_fees_cost: Amount = [credit_id, bounce_min_id, send_min_id, bounce_id]
.into_iter()
.map(|id| unsigned(client_rpc.get_tx(&id).unwrap().fee.unwrap()))
.reduce(|acc, i| acc + i)
@@ -148,7 +148,7 @@ pub fn btc_test(config: Option<&Path>, base_url: &str) {
let (tx, metadata) = client_rpc.get_tx_op_return(&tx.txid).unwrap();
let metadata = OutMetadata::decode(&metadata).unwrap();
match metadata {
- OutMetadata::Withdraw { .. } => {}
+ OutMetadata::Debit { .. } => {}
OutMetadata::Bounce { bounced } => {
let bounced = Txid::from_inner(bounced);
if bounced == bounce_id {
diff --git a/instrumentation/src/eth.rs b/instrumentation/src/eth.rs
@@ -70,8 +70,8 @@ pub fn eth_test(config: Option<&Path>, base_url: &str) {
println!("Send transaction");
let reserve_pub_key = rand_slice();
- let deposit_id = rpc
- .deposit(client_addr, state.address, test_amount, reserve_pub_key)
+ let credit_id = rpc
+ .credit(client_addr, state.address, test_amount, reserve_pub_key)
.unwrap();
let zero_id = rpc
.send_transaction(&TransactionRequest {
@@ -104,7 +104,7 @@ pub fn eth_test(config: Option<&Path>, base_url: &str) {
if tx.to.unwrap() == client_addr && tx.from.unwrap() == state.address {
let metadata = OutMetadata::decode(&tx.input).unwrap();
match metadata {
- OutMetadata::Withdraw { .. } => {}
+ OutMetadata::Debit { .. } => {}
OutMetadata::Bounce { bounced } => {
let bounced = H256::from_slice(&bounced);
if bounced == bounce_id {
@@ -127,7 +127,7 @@ pub fn eth_test(config: Option<&Path>, base_url: &str) {
let new_client_balance = rpc.get_balance(&client_addr).unwrap();
let new_wire_balance = rpc.get_balance(&state.address).unwrap();
let client_sent_amount_cost = test_amount * U256::from(2u8);
- let client_sent_fees_cost = [deposit_id, zero_id, bounce_id]
+ let client_sent_fees_cost = [credit_id, zero_id, bounce_id]
.into_iter()
.map(|id| {
let receipt = rpc.get_transaction_receipt(&id).unwrap().unwrap();
diff --git a/test/btc/hell.sh b/test/btc/hell.sh
@@ -20,7 +20,7 @@ echo "Start gateway"
gateway
echo ""
-echo "----- Handle reorg conflicting incoming deposit -----"
+echo "----- Handle reorg conflicting incoming credit -----"
echo "Loose second bitcoin node"
btc_deco
diff --git a/test/eth/analysis.sh b/test/eth/analysis.sh
@@ -26,7 +26,7 @@ echo "Loose second ethereum node"
eth_deco
echo -n "Making wire transfer to exchange:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.00 42
+$WIRE_UTILS credit $CLIENT $WIRE 0.00 42
next_eth # Trigger eth-wire
check_balance_eth 999580000 420000
echo " OK"
@@ -48,7 +48,7 @@ echo "Loose second bitcoin node"
eth_deco
echo -n "Making wire transfer to exchange:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.00 42
+$WIRE_UTILS credit $CLIENT $WIRE 0.00 42
next_eth # Trigger eth-wire
check_balance_eth 999160000 840000
echo " OK"
diff --git a/test/eth/bumpfee.sh b/test/eth/bumpfee.sh
@@ -23,7 +23,7 @@ echo ""
SEQ="seq 10 20"
echo -n "Making wire transfer to exchange: "
-$WIRE_UTILS deposit $CLIENT $WIRE 0.000 `$SEQ`
+$WIRE_UTILS credit $CLIENT $WIRE 0.000 `$SEQ`
sleep 1
mine_eth # Trigger eth-wire
check_balance_eth 999835000 165000
diff --git a/test/eth/hell.sh b/test/eth/hell.sh
@@ -20,13 +20,13 @@ echo "Start gateway"
gateway
echo ""
-echo "----- Handle reorg conflicting incoming deposit -----"
+echo "----- Handle reorg conflicting incoming credit -----"
echo "Loose second ethereum node"
eth_deco
echo -n "Making wire transfer to exchange:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.00 42
+$WIRE_UTILS credit $CLIENT $WIRE 0.00 42
next_eth # Trigger eth-wire
check_balance_eth 999580000 420000
echo " OK"
diff --git a/test/eth/lifetime.sh b/test/eth/lifetime.sh
@@ -29,7 +29,7 @@ check_up $GATEWAY_PID wire-gateway
echo " OK"
echo -n "Do some work:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.000 `$SEQ` > /dev/null
+$WIRE_UTILS credit $CLIENT $WIRE 0.000 `$SEQ` > /dev/null
next_eth # Trigger eth-wire
check_balance_eth 999835000 165000
for n in `$SEQ`; do
diff --git a/test/eth/maxfee.sh b/test/eth/maxfee.sh
@@ -21,7 +21,7 @@ echo ""
SEQ="seq 10 20"
echo -n "Making wire transfer to exchange: "
-$WIRE_UTILS deposit $CLIENT $WIRE 0.000 `$SEQ`
+$WIRE_UTILS credit $CLIENT $WIRE 0.000 `$SEQ`
next_eth # Trigger eth-wire
sleep 1
check_delta "incoming?delta=-100" "$SEQ" "0.000"
diff --git a/test/eth/reconnect.sh b/test/eth/reconnect.sh
@@ -21,7 +21,7 @@ echo ""
echo "----- With DB -----"
echo -n "Making wire transfer to exchange:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.0000 42
+$WIRE_UTILS credit $CLIENT $WIRE 0.0000 42
next_eth # Trigger eth-wire
check_balance_eth 999995800 4200
echo " OK"
@@ -37,7 +37,7 @@ stop_db
echo "Making incomplete wire transfer to exchange"
$WIRE_UTILS send $CLIENT $WIRE 0.0000 42
echo -n "Making wire transfer to exchange:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.0000 4
+$WIRE_UTILS credit $CLIENT $WIRE 0.0000 4
next_eth
check_balance_eth 999987600 12400
echo "OK"
diff --git a/test/eth/reorg.sh b/test/eth/reorg.sh
@@ -28,7 +28,7 @@ echo "Loose second ethereum node"
eth_deco
echo -n "Making wire transfer to exchange:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.000 `$SEQ`
+$WIRE_UTILS credit $CLIENT $WIRE 0.000 `$SEQ`
next_eth # Trigger eth-wire
check_delta "incoming?delta=-100" "$SEQ" "0.000"
check_balance_eth 999835000 165000
diff --git a/test/eth/stress.sh b/test/eth/stress.sh
@@ -23,7 +23,7 @@ SEQ="seq 10 30"
echo "----- Handle incoming -----"
echo -n "Making wire transfer to exchange:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.000 `$SEQ`
+$WIRE_UTILS credit $CLIENT $WIRE 0.000 `$SEQ`
next_eth # Trigger eth-wire
echo " OK"
diff --git a/test/eth/wire.sh b/test/eth/wire.sh
@@ -23,7 +23,7 @@ SEQ="seq 10 99"
echo "----- Receive -----"
echo -n "Making wire transfer to exchange:"
-$WIRE_UTILS deposit $CLIENT $WIRE 0.000 `$SEQ`
+$WIRE_UTILS credit $CLIENT $WIRE 0.000 `$SEQ`
next_eth # Trigger eth-wire
check_balance_eth 995095000 4905000
echo " OK"