mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 11:15:51 +00:00
Getter for addresses watched by wallet.
This commit is contained in:
parent
15060572a9
commit
72b7929523
@ -695,6 +695,22 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all addresses watched by this wallet.
|
||||
*/
|
||||
public List<Address> getWatchedAddresses() {
|
||||
lock.lock();
|
||||
try {
|
||||
List<Address> addresses = new LinkedList<Address>();
|
||||
for (Script script : watchedScripts)
|
||||
if (script.isSentToAddress())
|
||||
addresses.add(script.getToAddress(params));
|
||||
return addresses;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates a keypair from the basicKeyChain given the hash of the public key. This is needed when finding out which
|
||||
* key we need to use to redeem a transaction output.
|
||||
|
@ -1188,6 +1188,15 @@ public class WalletTest extends TestWithWallet {
|
||||
assertTrue(wallet.getBloomFilter(1e-12).contains(outPoint.bitcoinSerialize()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWatchedAddresses() throws Exception {
|
||||
Address watchedAddress = new ECKey().toAddress(params);
|
||||
wallet.addWatchedAddress(watchedAddress);
|
||||
List<Address> watchedAddresses = wallet.getWatchedAddresses();
|
||||
assertEquals(1, watchedAddresses.size());
|
||||
assertEquals(watchedAddress, watchedAddresses.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void marriedKeychainBloomFilter() throws Exception {
|
||||
wallet = new Wallet(params);
|
||||
|
Loading…
x
Reference in New Issue
Block a user