Make the internal state of `SentTransactionOutput` private.
This commit is contained in:
parent
ac3439e65e
commit
f3745c0cb5
|
@ -8,14 +8,15 @@ and this library adheres to Rust's notion of
|
|||
## [Unreleased]
|
||||
### Added
|
||||
- `data_api::SentTransactionOutput::from_parts`
|
||||
- `data_api::SentTransactionOutput::sapling_change_to`
|
||||
- `data_api::WalletRead::get_min_unspent_height`
|
||||
|
||||
### Changed
|
||||
- `decrypt::DecryptedOutput` is now parameterized by a `Note` type parameter,
|
||||
to allow reuse of the data structure for non-Sapling contexts.
|
||||
- `data_api::SentTransactionOutput` must now be constructed using
|
||||
`SentTransactionOutput::from_parts`
|
||||
`SentTransactionOutput::from_parts`. The internal state of `SentTransactionOutput`
|
||||
is now private, and accessible via methods that have the same names as the
|
||||
previously exposed fields.
|
||||
|
||||
### Renamed
|
||||
- The following types and fields have been renamed in preparation for supporting
|
||||
|
|
|
@ -291,20 +291,49 @@ pub enum Recipient {
|
|||
}
|
||||
|
||||
pub struct SentTransactionOutput {
|
||||
/// The index within the transaction that contains the recipient output.
|
||||
output_index: usize,
|
||||
recipient: Recipient,
|
||||
value: Amount,
|
||||
memo: Option<MemoBytes>,
|
||||
}
|
||||
|
||||
impl SentTransactionOutput {
|
||||
pub fn from_parts(
|
||||
output_index: usize,
|
||||
recipient: Recipient,
|
||||
value: Amount,
|
||||
memo: Option<MemoBytes>,
|
||||
) -> Self {
|
||||
Self {
|
||||
output_index,
|
||||
recipient,
|
||||
value,
|
||||
memo,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the index within the transaction that contains the recipient output.
|
||||
///
|
||||
/// - If `recipient_address` is a Sapling address, this is an index into the Sapling
|
||||
/// outputs of the transaction.
|
||||
/// - If `recipient_address` is a transparent address, this is an index into the
|
||||
/// transparent outputs of the transaction.
|
||||
pub output_index: usize,
|
||||
/// The recipient address of the transaction, or the account
|
||||
/// id for wallet-internal transactions.
|
||||
pub recipient: Recipient,
|
||||
/// The value of the newly created output
|
||||
pub value: Amount,
|
||||
/// The memo that was attached to the output, if any
|
||||
pub memo: Option<MemoBytes>,
|
||||
pub fn output_index(&self) -> usize {
|
||||
self.output_index
|
||||
}
|
||||
/// Returns the recipient address of the transaction, or the account id for wallet-internal
|
||||
/// transactions.
|
||||
pub fn recipient(&self) -> &Recipient {
|
||||
&self.recipient
|
||||
}
|
||||
/// Returns the value of the newly created output.
|
||||
pub fn value(&self) -> Amount {
|
||||
self.value
|
||||
}
|
||||
/// Returns the memo that was attached to the output, if any.
|
||||
pub fn memo(&self) -> Option<&MemoBytes> {
|
||||
self.memo.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
/// This trait encapsulates the write capabilities required to update stored
|
||||
|
|
|
@ -1078,11 +1078,11 @@ pub(crate) fn insert_sent_output<'a, P: consensus::Parameters>(
|
|||
) -> Result<(), SqliteClientError> {
|
||||
stmts.stmt_insert_sent_output(
|
||||
tx_ref,
|
||||
output.output_index,
|
||||
output.output_index(),
|
||||
from_account,
|
||||
&output.recipient,
|
||||
output.value,
|
||||
output.memo.as_ref(),
|
||||
output.recipient(),
|
||||
output.value(),
|
||||
output.memo(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue