Skip to content

Commit acef71f

Browse files
committed
fix(types): use f64 for DecodePsbt fee field
Bitcoin Core returns the fee as a floating-point BTC value, not satoshis. Change fee field from u64 to f64 and update conversion to use Amount::from_btc() instead of Amount::from_sat(). Affected versions: v17, v23, v24, v30
1 parent 68cebe1 commit acef71f

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

types/src/v17/raw_transactions/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl DecodePsbt {
124124

125125
let psbt =
126126
bitcoin::Psbt { unsigned_tx, version, xpub, proprietary, unknown, inputs, outputs };
127-
let fee = self.fee.map(Amount::from_sat);
127+
let fee = self.fee.map(Amount::from_btc).transpose().map_err(E::Fee)?;
128128

129129
Ok(model::DecodePsbt { psbt, fee })
130130
}

types/src/v17/raw_transactions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub struct DecodePsbt {
143143
/// Array of transaction outputs.
144144
pub outputs: Vec<PsbtOutput>,
145145
/// The transaction fee paid if all UTXOs slots in the PSBT have been filled.
146-
pub fee: Option<u64>,
146+
pub fee: Option<f64>,
147147
}
148148

149149
/// An input in a partially signed Bitcoin transaction. Part of `decodepsbt`.

types/src/v23/raw_transactions/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl DecodePsbt {
6767
inputs,
6868
outputs,
6969
};
70-
let fee = self.fee.map(Amount::from_sat);
70+
let fee = self.fee.map(Amount::from_btc).transpose().map_err(E::Fee)?;
7171

7272
Ok(model::DecodePsbt { psbt, fee })
7373
}

types/src/v23/raw_transactions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct DecodePsbt {
4747
/// Array of transaction outputs.
4848
pub outputs: Vec<PsbtOutput>,
4949
/// The transaction fee paid if all UTXOs slots in the PSBT have been filled.
50-
pub fee: Option<u64>,
50+
pub fee: Option<f64>,
5151
}
5252

5353
/// An item from the global xpubs list. Part of `decodepsbt`.

types/src/v24/raw_transactions/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl DecodePsbt {
7272
inputs,
7373
outputs,
7474
};
75-
let fee = self.fee.map(Amount::from_sat);
75+
let fee = self.fee.map(Amount::from_btc).transpose().map_err(E::Fee)?;
7676

7777
Ok(model::DecodePsbt { psbt, fee })
7878
}

types/src/v24/raw_transactions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct DecodePsbt {
4848
/// Array of transaction outputs.
4949
pub outputs: Vec<PsbtOutput>,
5050
/// The transaction fee paid if all UTXOs slots in the PSBT have been filled.
51-
pub fee: Option<u64>,
51+
pub fee: Option<f64>,
5252
}
5353

5454
/// An item from the global xpubs list. Part of `decodepsbt`.

types/src/v30/raw_transactions/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl DecodePsbt {
7272
inputs,
7373
outputs,
7474
};
75-
let fee = self.fee.map(Amount::from_sat);
75+
let fee = self.fee.map(Amount::from_btc).transpose().map_err(E::Fee)?;
7676

7777
Ok(model::DecodePsbt { psbt, fee })
7878
}

types/src/v30/raw_transactions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct DecodePsbt {
4848
/// Array of transaction outputs.
4949
pub outputs: Vec<PsbtOutput>,
5050
/// The transaction fee paid if all UTXOs slots in the PSBT have been filled.
51-
pub fee: Option<u64>,
51+
pub fee: Option<f64>,
5252
}
5353

5454
/// An item from the global xpubs list. Part of `decodepsbt`.

0 commit comments

Comments
 (0)