diff --git a/masp_primitives/src/transaction/builder.rs b/masp_primitives/src/transaction/builder.rs index 993f5ddf..ed3c05ce 100644 --- a/masp_primitives/src/transaction/builder.rs +++ b/masp_primitives/src/transaction/builder.rs @@ -153,7 +153,7 @@ impl Builder { /// Returns the set of Sapling inputs currently committed to be consumed /// by the transaction. - pub fn sapling_inputs(&self) -> &[impl sapling::fees::InputView<()>] { + pub fn sapling_inputs(&self) -> &[impl sapling::fees::InputView<(), K>] { self.sapling_builder.inputs() } diff --git a/masp_primitives/src/transaction/components/sapling/builder.rs b/masp_primitives/src/transaction/components/sapling/builder.rs index 2881994f..f51b8c51 100644 --- a/masp_primitives/src/transaction/components/sapling/builder.rs +++ b/masp_primitives/src/transaction/components/sapling/builder.rs @@ -103,7 +103,7 @@ impl BorshDeserialize for SpendDescriptionInfo { } } -impl fees::InputView<()> for SpendDescriptionInfo { +impl fees::InputView<(), K> for SpendDescriptionInfo { fn note_id(&self) -> &() { // The builder does not make use of note identifiers, so we can just return the unit value. &() @@ -116,6 +116,10 @@ impl fees::InputView<()> for SpendDescriptionInfo { fn asset_type(&self) -> AssetType { self.note.asset_type } + + fn key(&self) -> &K { + &self.extsk + } } /// A struct containing the information required in order to construct a @@ -207,6 +211,10 @@ impl fees::OutputView for SaplingOutputInfo { fn asset_type(&self) -> AssetType { self.note.asset_type } + + fn address(&self) -> PaymentAddress { + self.to + } } /// Metadata about a transaction created by a [`SaplingBuilder`]. @@ -349,7 +357,7 @@ impl SaplingBuilder { /// Returns the list of Sapling inputs that will be consumed by the transaction being /// constructed. - pub fn inputs(&self) -> &[impl fees::InputView<()>] { + pub fn inputs(&self) -> &[impl fees::InputView<(), K>] { &self.spends } diff --git a/masp_primitives/src/transaction/components/sapling/fees.rs b/masp_primitives/src/transaction/components/sapling/fees.rs index 5bd01d03..81eea72b 100644 --- a/masp_primitives/src/transaction/components/sapling/fees.rs +++ b/masp_primitives/src/transaction/components/sapling/fees.rs @@ -2,16 +2,19 @@ //! of a transaction. use crate::asset_type::AssetType; +use crate::sapling::PaymentAddress; /// A trait that provides a minimized view of a Sapling input suitable for use in /// fee and change calculation. -pub trait InputView { +pub trait InputView { /// An identifier for the input being spent. fn note_id(&self) -> &NoteRef; /// The value of the input being spent. fn value(&self) -> u64; /// The asset type of the input being spent. fn asset_type(&self) -> AssetType; + /// The spend/view key of the input being spent. + fn key(&self) -> &Key; } /// A trait that provides a minimized view of a Sapling output suitable for use in @@ -21,4 +24,6 @@ pub trait OutputView { fn value(&self) -> u64; /// The asset type of the output being produced. fn asset_type(&self) -> AssetType; + /// The destination of this output + fn address(&self) -> PaymentAddress; }