Java Code Examples for org.bitcoinj.wallet.Wallet#addScriptChangeEventListener()

The following examples show how to use org.bitcoinj.wallet.Wallet#addScriptChangeEventListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PeerGroup.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * <p>Link the given wallet to this PeerGroup. This is used for three purposes:</p>
 * <p>
 * <ol>
 * <li>So the wallet receives broadcast transactions.</li>
 * <li>Announcing pending transactions that didn't get into the chain yet to our peers.</li>
 * <li>Set the fast catchup time using {@link PeerGroup#setFastCatchupTimeSecs(long)}, to optimize chain
 * download.</li>
 * </ol>
 * <p>
 * <p>Note that this should be done before chain download commences because if you add a wallet with keys earlier
 * than the current chain head, the relevant parts of the chain won't be redownloaded for you.</p>
 * <p>
 * <p>The Wallet will have an event listener registered on it, so to avoid leaks remember to use
 * {@link PeerGroup#removeWallet(Wallet)} on it if you wish to keep the Wallet but lose the PeerGroup.</p>
 */
public void addWallet(Wallet wallet) {
    lock.lock();
    try {
        checkNotNull(wallet);
        checkState(!wallets.contains(wallet));
        wallets.add(wallet);
        wallet.setTransactionBroadcaster(this);
        wallet.addCoinsReceivedEventListener(Threading.SAME_THREAD, walletCoinsReceivedEventListener);
        wallet.addKeyChainEventListener(Threading.SAME_THREAD, walletKeyEventListener);
        wallet.addScriptChangeEventListener(Threading.SAME_THREAD, walletScriptEventListener);
        addPeerFilterProvider(wallet);
        for (Peer peer : peers) {
            peer.addWallet(wallet);
        }
    } finally {
        lock.unlock();
    }
}
 
Example 2
Source File: PeerGroup.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * <p>Link the given wallet to this PeerGroup. This is used for three purposes:</p>
 *
 * <ol>
 *   <li>So the wallet receives broadcast transactions.</li>
 *   <li>Announcing pending transactions that didn't get into the chain yet to our peers.</li>
 *   <li>Set the fast catchup time using {@link PeerGroup#setFastCatchupTimeSecs(long)}, to optimize chain
 *       download.</li>
 * </ol>
 *
 * <p>Note that this should be done before chain download commences because if you add a wallet with keys earlier
 * than the current chain head, the relevant parts of the chain won't be redownloaded for you.</p>
 *
 * <p>The Wallet will have an event listener registered on it, so to avoid leaks remember to use
 * {@link PeerGroup#removeWallet(Wallet)} on it if you wish to keep the Wallet but lose the PeerGroup.</p>
 */
public void addWallet(Wallet wallet) {
    lock.lock();
    try {
        checkNotNull(wallet);
        checkState(!wallets.contains(wallet));
        wallets.add(wallet);
        wallet.setTransactionBroadcaster(this);
        wallet.addCoinsReceivedEventListener(Threading.SAME_THREAD, walletCoinsReceivedEventListener);
        wallet.addKeyChainEventListener(Threading.SAME_THREAD, walletKeyEventListener);
        wallet.addScriptChangeEventListener(Threading.SAME_THREAD, walletScriptEventListener);
        addPeerFilterProvider(wallet);
        for (Peer peer : peers) {
            peer.addWallet(wallet);
        }
    } finally {
        lock.unlock();
    }
}
 
Example 3
Source File: PeerGroup.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
/**
 * <p>Link the given wallet to this PeerGroup. This is used for three purposes:</p>
 *
 * <ol>
 *   <li>So the wallet receives broadcast transactions.</li>
 *   <li>Announcing pending transactions that didn't get into the chain yet to our peers.</li>
 *   <li>Set the fast catchup time using {@link PeerGroup#setFastCatchupTimeSecs(long)}, to optimize chain
 *       download.</li>
 * </ol>
 *
 * <p>Note that this should be done before chain download commences because if you add a wallet with keys earlier
 * than the current chain head, the relevant parts of the chain won't be redownloaded for you.</p>
 *
 * <p>The Wallet will have an event listener registered on it, so to avoid leaks remember to use
 * {@link PeerGroup#removeWallet(Wallet)} on it if you wish to keep the Wallet but lose the PeerGroup.</p>
 */
public void addWallet(Wallet wallet) {
    lock.lock();
    try {
        checkNotNull(wallet);
        checkState(!wallets.contains(wallet));
        wallets.add(wallet);
        wallet.setTransactionBroadcaster(this);
        wallet.addCoinsReceivedEventListener(Threading.SAME_THREAD, walletCoinsReceivedEventListener);
        wallet.addKeyChainEventListener(Threading.SAME_THREAD, walletKeyEventListener);
        wallet.addScriptChangeEventListener(Threading.SAME_THREAD, walletScriptEventListener);
        addPeerFilterProvider(wallet);
        for (Peer peer : peers) {
            peer.addWallet(wallet);
        }
    } finally {
        lock.unlock();
    }
}