commit 245d087e721b0cb661d8ff483484e4ed0485cf44
parent c16d2034a4ff46e12a08f7babb00053ee9685466
Author: Antoine A <>
Date: Thu, 17 Feb 2022 16:30:49 +0100
Cleaning and replace code requiring rust version > 1.56.1
Diffstat:
6 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/btc-wire/src/bin/segwit-demo.rs b/btc-wire/src/bin/segwit-demo.rs
@@ -12,8 +12,14 @@ pub fn main() {
let btc = amount.as_btc();
println!("Ⅰ - Parse payto uri");
- println!("Got payto uri: payto://bitcoin/{address}?amount=BTC:{btc}&subject={reserve_pub}");
- println!("Send {btc} BTC to {address} with reserve public key {reserve_pub}");
+ println!(
+ "Got payto uri: payto://bitcoin/{}?amount=BTC:{}&subject={}",
+ address, btc, reserve_pub
+ );
+ println!(
+ "Send {} BTC to {} with reserve public key {}",
+ btc, address, reserve_pub
+ );
println!("\nⅡ - Generate fake segwit addresses");
let decoded: [u8; 32] = base32::decode(Alphabet::Crockford, reserve_pub)
@@ -55,11 +61,11 @@ pub fn main() {
println!("Send a single bitcoin transaction with the three addresses as recipient as follow:");
println!("\nIn bitcoincore wallet use 'Add Recipient' button to add two additional recipient and copy adresses and amounts");
for (address, amount) in [(address, btc), (&first, minimum), (&second, minimum)] {
- println!("{address} {amount:.8} BTC");
+ println!("{} {:.8} BTC", address, amount);
}
println!("\nIn Electrum wallet paste the following three lines in 'Pay to' field :");
for (address, amount) in [(address, btc), (&first, minimum), (&second, minimum)] {
- println!("{address},{amount:.8}");
+ println!("{},{:.8}", address, amount);
}
println!(
"Make sure the amount show 0.10000588 BTC, else you have to change the base unit to BTC"
diff --git a/btc-wire/src/loops/analysis.rs b/btc-wire/src/loops/analysis.rs
@@ -42,7 +42,7 @@ pub fn analysis(mut rpc: AutoRpcCommon, mut db: AutoReconnectDb, state: &WireSta
.get_chain_tips()?
.into_iter()
.filter_map(|t| {
- (t.status == ChainTipsStatus::ValidFork).then(|| t.branch_length)
+ (t.status == ChainTipsStatus::ValidFork).then(|| t.length)
})
.max()
.unwrap_or(0) as u16;
diff --git a/btc-wire/src/loops/watcher.rs b/btc-wire/src/loops/watcher.rs
@@ -1,4 +1,3 @@
-use btc_wire::rpc::AutoRpcCommon;
/*
This file is part of TALER
Copyright (C) 2022 Taler Systems SA
@@ -15,6 +14,7 @@ use btc_wire::rpc::AutoRpcCommon;
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
use common::{log::log::error, reconnect::AutoReconnectDb};
+use btc_wire::rpc::AutoRpcCommon;
use super::LoopResult;
diff --git a/btc-wire/src/rpc.rs b/btc-wire/src/rpc.rs
@@ -306,17 +306,17 @@ impl Rpc {
}
/// Send bitcoin transaction with multiple recipients
- pub fn send_many<'a, 'b>(
+ pub fn send_many<'a>(
&mut self,
- to: impl IntoIterator<Item = (&'a Address, &'b Amount)>,
+ to: impl IntoIterator<Item = (&'a Address, &'a Amount)>,
) -> Result<Txid> {
self.send_custom([], to, None, false).map(|it| it.txid)
}
- fn send_custom<'a, 'b, 'c>(
+ fn send_custom<'a>(
&mut self,
from: impl IntoIterator<Item = &'a Txid>,
- to: impl IntoIterator<Item = (&'b Address, &'c Amount)>,
+ to: impl IntoIterator<Item = (&'a Address, &'a Amount)>,
data: Option<&[u8]>,
subtract_fee: bool,
) -> Result<SendResult> {
@@ -357,10 +357,12 @@ impl Rpc {
)
}
+ /// Bump transaction fees of a wallet debit
pub fn bump_fee(&mut self, id: &Txid) -> Result<BumpResult> {
self.call("bumpfee", &[id])
}
+ /// Abandon a pending transaction
pub fn abandon_tx(&mut self, id: &Txid) -> Result<()> {
match self.call("abandontransaction", &[&id]) {
Err(Error::Null) => Ok(()),
@@ -385,14 +387,6 @@ impl Rpc {
}
}
-#[derive(Debug, serde::Serialize)]
-pub struct SendOption {
- pub add_inputs: bool,
- pub inputs: Vec<Value>,
- pub subtract_fee_from_outputs: Vec<usize>,
- pub replaceable: bool,
-}
-
#[derive(Debug, serde::Deserialize)]
pub struct Wallet {
pub name: String,
@@ -410,6 +404,14 @@ pub struct BumpResult {
pub txid: Txid,
}
+#[derive(Debug, serde::Serialize)]
+pub struct SendOption {
+ pub add_inputs: bool,
+ pub inputs: Vec<Value>,
+ pub subtract_fee_from_outputs: Vec<usize>,
+ pub replaceable: bool,
+}
+
#[derive(Debug, serde::Deserialize)]
pub struct SendResult {
pub txid: Txid,
@@ -432,7 +434,6 @@ pub struct TransactionDetail {
pub category: Category,
#[serde(with = "bitcoin::util::amount::serde::as_btc")]
pub amount: SignedAmount,
- pub vout: u32,
#[serde(default, with = "bitcoin::util::amount::serde::as_btc::opt")]
pub fee: Option<SignedAmount>,
/// Ony for send transaction
@@ -472,7 +473,6 @@ pub struct Vout {
#[derive(Debug, serde::Deserialize)]
pub struct Vin {
- pub sequence: u32,
/// Not provided for coinbase txs.
pub txid: Option<Txid>,
/// Not provided for coinbase txs.
@@ -501,10 +501,8 @@ pub struct Transaction {
#[derive(Clone, PartialEq, Eq, serde::Deserialize, Debug)]
pub struct ChainTips {
- pub height: u64,
- pub hash: bitcoin::BlockHash,
#[serde(rename = "branchlen")]
- pub branch_length: usize,
+ pub length: usize,
pub status: ChainTipsStatus,
}
diff --git a/common/src/lib.rs b/common/src/lib.rs
@@ -36,7 +36,7 @@ pub mod status;
/// Secure random slice generator using getrandom
pub fn rand_slice<const N: usize>() -> [u8; N] {
let mut slice = [0; N];
- OsRng.fill_bytes(slice.as_mut_slice());
+ OsRng.fill_bytes(&mut slice);
slice
}
diff --git a/wire-gateway/src/main.rs b/wire-gateway/src/main.rs
@@ -492,7 +492,7 @@ fn status_watcher(state: &'static ServerState) {
loop {
if let Err(err) = inner(state) {
- error!("status-watcher: {err}");
+ error!("status-watcher: {}", err);
}
std::thread::sleep(Duration::from_secs(5));
}