-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1008 from fluidvanadium/propose
Propose
- Loading branch information
Showing
5 changed files
with
150 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//! this mod brings input source functionality from transaction_records_by_id | ||
use zcash_client_backend::{ | ||
data_api::{InputSource, SpendableNotes}, | ||
wallet::NoteId, | ||
}; | ||
|
||
use super::{error::TxMapAndMaybeTreesError, TxMapAndMaybeTrees}; | ||
|
||
/// A trait representing the capability to query a data store for unspent transaction outputs belonging to a wallet. | ||
/// combining this with WalletRead unlocks propose_transaction | ||
/// all implementations in this file redirect to transaction_records_by_id | ||
impl InputSource for TxMapAndMaybeTrees { | ||
type Error = TxMapAndMaybeTreesError; | ||
type AccountId = zcash_primitives::zip32::AccountId; | ||
type NoteRef = NoteId; | ||
|
||
fn get_spendable_note( | ||
&self, | ||
txid: &zcash_primitives::transaction::TxId, | ||
protocol: zcash_client_backend::ShieldedProtocol, | ||
index: u32, | ||
) -> Result< | ||
Option< | ||
zcash_client_backend::wallet::ReceivedNote< | ||
Self::NoteRef, | ||
zcash_client_backend::wallet::Note, | ||
>, | ||
>, | ||
Self::Error, | ||
> { | ||
self.transaction_records_by_id | ||
.get_spendable_note(txid, protocol, index) | ||
.map_err(TxMapAndMaybeTreesError::InputSource) | ||
} | ||
|
||
fn select_spendable_notes( | ||
&self, | ||
account: Self::AccountId, | ||
target_value: zcash_primitives::transaction::components::amount::NonNegativeAmount, | ||
sources: &[zcash_client_backend::ShieldedProtocol], | ||
anchor_height: zcash_primitives::consensus::BlockHeight, | ||
exclude: &[Self::NoteRef], | ||
) -> Result<SpendableNotes<Self::NoteRef>, Self::Error> { | ||
self.transaction_records_by_id | ||
.select_spendable_notes(account, target_value, sources, anchor_height, exclude) | ||
.map_err(TxMapAndMaybeTreesError::InputSource) | ||
} | ||
|
||
fn get_unspent_transparent_output( | ||
&self, | ||
outpoint: &zcash_primitives::transaction::components::OutPoint, | ||
) -> Result<Option<zcash_client_backend::wallet::WalletTransparentOutput>, Self::Error> { | ||
self.transaction_records_by_id | ||
.get_unspent_transparent_output(outpoint) | ||
.map_err(TxMapAndMaybeTreesError::InputSource) | ||
} | ||
|
||
fn get_unspent_transparent_outputs( | ||
&self, | ||
address: &zcash_primitives::legacy::TransparentAddress, | ||
max_height: zcash_primitives::consensus::BlockHeight, | ||
exclude: &[zcash_primitives::transaction::components::OutPoint], | ||
) -> Result<Vec<zcash_client_backend::wallet::WalletTransparentOutput>, Self::Error> { | ||
self.transaction_records_by_id | ||
.get_unspent_transparent_outputs(address, max_height, exclude) | ||
.map_err(TxMapAndMaybeTreesError::InputSource) | ||
} | ||
} |