Skip to content

Commit 164cbe2

Browse files
committed
Use signed amount in gettransaction
We mistakenly used an `Amount` when the amount type returned by `gettransaction` can be negative. Use `SignedAmount` instead of `Amount`.
1 parent 51fe3b5 commit 164cbe2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

types/src/model/wallet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub struct GetReceivedByAddress(pub Amount);
277277
pub struct GetTransaction {
278278
/// The transaction amount.
279279
#[serde(default, with = "bitcoin::amount::serde::as_btc")]
280-
pub amount: Amount,
280+
pub amount: SignedAmount,
281281
/// The amount of the fee.
282282
///
283283
/// This is negative and only available for the 'send' category of transactions.

types/src/v17/wallet/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl GetTransaction {
325325
pub fn into_model(self) -> Result<model::GetTransaction, GetTransactionError> {
326326
use GetTransactionError as E;
327327

328-
let amount = Amount::from_btc(self.amount).map_err(E::Amount)?;
328+
let amount = SignedAmount::from_btc(self.amount).map_err(E::Amount)?;
329329
let fee = self.fee.map(|fee| SignedAmount::from_btc(fee).map_err(E::Fee)).transpose()?;
330330

331331
let block_hash =

0 commit comments

Comments
 (0)