@@ -88,16 +88,16 @@ use zcash_primitives::{
88
88
consensus:: BlockHeight ,
89
89
memo:: { Memo , MemoBytes } ,
90
90
transaction:: {
91
- components:: amount:: { BalanceError , NonNegativeAmount } ,
91
+ components:: {
92
+ amount:: { BalanceError , NonNegativeAmount } ,
93
+ OutPoint ,
94
+ } ,
92
95
Transaction , TxId ,
93
96
} ,
94
97
} ;
95
98
96
99
#[ cfg( feature = "transparent-inputs" ) ]
97
- use {
98
- crate :: wallet:: TransparentAddressMetadata ,
99
- zcash_primitives:: { legacy:: TransparentAddress , transaction:: components:: OutPoint } ,
100
- } ;
100
+ use { crate :: wallet:: TransparentAddressMetadata , zcash_primitives:: legacy:: TransparentAddress } ;
101
101
102
102
#[ cfg( any( test, feature = "test-dependencies" ) ) ]
103
103
use zcash_primitives:: consensus:: NetworkUpgrade ;
@@ -909,6 +909,16 @@ pub trait WalletRead {
909
909
) -> Result < HashMap < TransparentAddress , NonNegativeAmount > , Self :: Error > {
910
910
Ok ( HashMap :: new ( ) )
911
911
}
912
+
913
+ /// Returns the set of reserved ephemeral addresses controlled by this wallet.
914
+ #[ cfg( feature = "transparent-inputs" ) ]
915
+ fn get_reserved_ephemeral_addresses (
916
+ & self ,
917
+ _account : Self :: AccountId ,
918
+ _for_sync : bool ,
919
+ ) -> Result < Vec < TransparentAddress > , Self :: Error > {
920
+ Ok ( vec ! [ ] )
921
+ }
912
922
}
913
923
914
924
/// The relevance of a seed to a given wallet.
@@ -1239,7 +1249,7 @@ impl<'a, AccountId> SentTransaction<'a, AccountId> {
1239
1249
/// This type is capable of representing both shielded and transparent outputs.
1240
1250
pub struct SentTransactionOutput < AccountId > {
1241
1251
output_index : usize ,
1242
- recipient : Recipient < AccountId , Note > ,
1252
+ recipient : Recipient < AccountId , Note , OutPoint > ,
1243
1253
value : NonNegativeAmount ,
1244
1254
memo : Option < MemoBytes > ,
1245
1255
}
@@ -1256,7 +1266,7 @@ impl<AccountId> SentTransactionOutput<AccountId> {
1256
1266
/// * `memo` - the memo that was sent with this output
1257
1267
pub fn from_parts (
1258
1268
output_index : usize ,
1259
- recipient : Recipient < AccountId , Note > ,
1269
+ recipient : Recipient < AccountId , Note , OutPoint > ,
1260
1270
value : NonNegativeAmount ,
1261
1271
memo : Option < MemoBytes > ,
1262
1272
) -> Self {
@@ -1278,8 +1288,8 @@ impl<AccountId> SentTransactionOutput<AccountId> {
1278
1288
self . output_index
1279
1289
}
1280
1290
/// Returns the recipient address of the transaction, or the account id and
1281
- /// resulting note for wallet-internal outputs.
1282
- pub fn recipient ( & self ) -> & Recipient < AccountId , Note > {
1291
+ /// resulting note/outpoint for wallet-internal outputs.
1292
+ pub fn recipient ( & self ) -> & Recipient < AccountId , Note , OutPoint > {
1283
1293
& self . recipient
1284
1294
}
1285
1295
/// Returns the value of the newly created output.
@@ -1514,8 +1524,11 @@ pub trait WalletWrite: WalletRead {
1514
1524
received_tx : DecryptedTransaction < Self :: AccountId > ,
1515
1525
) -> Result < ( ) , Self :: Error > ;
1516
1526
1517
- /// Saves information about a transaction that was constructed and sent by the wallet to the
1518
- /// persistent wallet store.
1527
+ /// Saves information about a transaction constructed by the wallet to the persistent
1528
+ /// wallet store.
1529
+ ///
1530
+ /// The name `store_sent_tx` is somewhat misleading; this must be called *before* the
1531
+ /// transaction is sent to the network.
1519
1532
fn store_sent_tx (
1520
1533
& mut self ,
1521
1534
sent_tx : & SentTransaction < Self :: AccountId > ,
@@ -1535,6 +1548,26 @@ pub trait WalletWrite: WalletRead {
1535
1548
///
1536
1549
/// There may be restrictions on heights to which it is possible to truncate.
1537
1550
fn truncate_to_height ( & mut self , block_height : BlockHeight ) -> Result < ( ) , Self :: Error > ;
1551
+
1552
+ /// Reserves the next `n` available ephemeral addresses for the given account.
1553
+ /// This cannot be undone, so as far as possible, errors associated with transaction
1554
+ /// construction should have been reported before calling this method.
1555
+ ///
1556
+ /// To ensure that sufficient information is stored on-chain to allow recovering
1557
+ /// funds sent back to any of the used addresses, a "gap limit" of 20 addresses
1558
+ /// should be observed as described in [BIP 44].
1559
+ ///
1560
+ /// Returns an error if there is insufficient space within the gap limit to allocate
1561
+ /// the given number of addresses, or if the account identifier does not correspond
1562
+ /// to a known account.
1563
+ ///
1564
+ /// [BIP 44]: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#user-content-Address_gap_limit
1565
+ #[ cfg( feature = "transparent-inputs" ) ]
1566
+ fn reserve_next_n_ephemeral_addresses (
1567
+ & mut self ,
1568
+ account_id : Self :: AccountId ,
1569
+ n : u32 ,
1570
+ ) -> Result < Vec < TransparentAddress > , Self :: Error > ;
1538
1571
}
1539
1572
1540
1573
/// This trait describes a capability for manipulating wallet note commitment trees.
@@ -1862,6 +1895,15 @@ pub mod testing {
1862
1895
) -> Result < HashMap < TransparentAddress , NonNegativeAmount > , Self :: Error > {
1863
1896
Ok ( HashMap :: new ( ) )
1864
1897
}
1898
+
1899
+ #[ cfg( feature = "transparent-inputs" ) ]
1900
+ fn get_reserved_ephemeral_addresses (
1901
+ & self ,
1902
+ _account : Self :: AccountId ,
1903
+ _for_sync : bool ,
1904
+ ) -> Result < Vec < TransparentAddress > , Self :: Error > {
1905
+ Ok ( vec ! [ ] )
1906
+ }
1865
1907
}
1866
1908
1867
1909
impl WalletWrite for MockWalletDb {
@@ -1924,6 +1966,15 @@ pub mod testing {
1924
1966
) -> Result < Self :: UtxoRef , Self :: Error > {
1925
1967
Ok ( 0 )
1926
1968
}
1969
+
1970
+ #[ cfg( feature = "transparent-inputs" ) ]
1971
+ fn reserve_next_n_ephemeral_addresses (
1972
+ & mut self ,
1973
+ _account_id : Self :: AccountId ,
1974
+ _n : u32 ,
1975
+ ) -> Result < Vec < TransparentAddress > , Self :: Error > {
1976
+ Err ( ( ) )
1977
+ }
1927
1978
}
1928
1979
1929
1980
impl WalletCommitmentTrees for MockWalletDb {
0 commit comments