Merge bitcoindevkit/bdk#785: Fix wallet export rescan height
e9bbb8724f92ada33228bbfc22acdaefbd79c44e Fix wallet export rescan height (LLFourn) Pull request description: It would return the latest transaction height rather than the earliest as the height to rescan from. Found by @evanlinjin and I while implementing `bdk_core` stuff into bdk's wallet. ### Changelog notice - Fix wallet export transaction height #### All Submissions: * [x] I've signed all my commits * [x] This pull request breaks the existing API * [x] I've added tests to reproduce the issue which are now passing ACKs for top commit: rajarshimaitra: tACK e9bbb8724f92ada33228bbfc22acdaefbd79c44e notmandatory: ACK e9bbb8724f92ada33228bbfc22acdaefbd79c44e Tree-SHA512: 9b29ef0df39d26806f48b38fa5c3643bad32f58b993ffdcfc7811aca64a025bd8f163967321f874aa2ef3d29c3e7bc6e2f44d348306a37111f4def036d4c095e
This commit is contained in:
commit
108edc3a6b
@ -134,15 +134,11 @@ impl FullyNodedExport {
|
|||||||
let blockheight = match wallet.database.borrow().iter_txs(false) {
|
let blockheight = match wallet.database.borrow().iter_txs(false) {
|
||||||
_ if !include_blockheight => 0,
|
_ if !include_blockheight => 0,
|
||||||
Err(_) => 0,
|
Err(_) => 0,
|
||||||
Ok(txs) => {
|
Ok(txs) => txs
|
||||||
let mut heights = txs
|
.into_iter()
|
||||||
.into_iter()
|
.filter_map(|tx| tx.confirmation_time.map(|c| c.height))
|
||||||
.map(|tx| tx.confirmation_time.map(|c| c.height).unwrap_or(0))
|
.min()
|
||||||
.collect::<Vec<_>>();
|
.unwrap_or(0),
|
||||||
heights.sort_unstable();
|
|
||||||
|
|
||||||
*heights.last().unwrap_or(&0)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let export = FullyNodedExport {
|
let export = FullyNodedExport {
|
||||||
@ -249,6 +245,22 @@ mod test {
|
|||||||
fee: Some(500),
|
fee: Some(500),
|
||||||
confirmation_time: Some(BlockTime {
|
confirmation_time: Some(BlockTime {
|
||||||
timestamp: 12345678,
|
timestamp: 12345678,
|
||||||
|
height: 5001,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
db.set_tx(&TransactionDetails {
|
||||||
|
transaction: None,
|
||||||
|
txid: Txid::from_str(
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
received: 25_000,
|
||||||
|
sent: 0,
|
||||||
|
fee: Some(300),
|
||||||
|
confirmation_time: Some(BlockTime {
|
||||||
|
timestamp: 12345677,
|
||||||
height: 5000,
|
height: 5000,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user