com.google.bitcoin.protocols.channels
Class StoredPaymentChannelClientStates

java.lang.Object
  extended by com.google.bitcoin.protocols.channels.StoredPaymentChannelClientStates
All Implemented Interfaces:
WalletExtension

public class StoredPaymentChannelClientStates
extends Object
implements WalletExtension

This class maintains a set of StoredClientChannels, automatically (re)broadcasting the contract transaction and broadcasting the refund transaction over the given TransactionBroadcaster.


Field Summary
protected  ReentrantLock lock
           
 
Constructor Summary
StoredPaymentChannelClientStates(Wallet containingWallet, TransactionBroadcaster announcePeerGroup)
          Creates a new StoredPaymentChannelClientStates and associates it with the given Wallet and TransactionBroadcaster which are used to complete and announce contract and refund transactions.
 
Method Summary
 void deserializeWalletExtension(Wallet containingWallet, byte[] data)
          Loads the contents of this object from the wallet.
 BigInteger getBalanceForServer(Sha256Hash id)
          Returns the outstanding amount of money sent back to us for all channels to this server added together.
static StoredPaymentChannelClientStates getFromWallet(Wallet wallet)
          Returns this extension from the given wallet, or null if no such extension was added.
 long getSecondsUntilExpiry(Sha256Hash id)
          Returns the number of seconds from now until this servers next channel will expire, or zero if no unexpired channels found.
 String getWalletExtensionID()
          Returns a Java package/class style name used to disambiguate this extension from others.
 boolean isWalletExtensionMandatory()
          If this returns true, the mandatory flag is set when the wallet is serialized and attempts to load it without the extension being in the wallet will throw an exception.
 byte[] serializeWalletExtension()
          Returns bytes that will be saved in the wallet.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lock

protected final ReentrantLock lock
Constructor Detail

StoredPaymentChannelClientStates

public StoredPaymentChannelClientStates(Wallet containingWallet,
                                        TransactionBroadcaster announcePeerGroup)
Creates a new StoredPaymentChannelClientStates and associates it with the given Wallet and TransactionBroadcaster which are used to complete and announce contract and refund transactions.

Method Detail

getFromWallet

@Nullable
public static StoredPaymentChannelClientStates getFromWallet(Wallet wallet)
Returns this extension from the given wallet, or null if no such extension was added.


getBalanceForServer

public BigInteger getBalanceForServer(Sha256Hash id)
Returns the outstanding amount of money sent back to us for all channels to this server added together.


getSecondsUntilExpiry

public long getSecondsUntilExpiry(Sha256Hash id)
Returns the number of seconds from now until this servers next channel will expire, or zero if no unexpired channels found.


getWalletExtensionID

public String getWalletExtensionID()
Description copied from interface: WalletExtension
Returns a Java package/class style name used to disambiguate this extension from others.

Specified by:
getWalletExtensionID in interface WalletExtension

isWalletExtensionMandatory

public boolean isWalletExtensionMandatory()
Description copied from interface: WalletExtension
If this returns true, the mandatory flag is set when the wallet is serialized and attempts to load it without the extension being in the wallet will throw an exception. This method should not change its result during the objects lifetime.

Specified by:
isWalletExtensionMandatory in interface WalletExtension

serializeWalletExtension

public byte[] serializeWalletExtension()
Description copied from interface: WalletExtension
Returns bytes that will be saved in the wallet.

Specified by:
serializeWalletExtension in interface WalletExtension

deserializeWalletExtension

public void deserializeWalletExtension(Wallet containingWallet,
                                       byte[] data)
                                throws Exception
Description copied from interface: WalletExtension
Loads the contents of this object from the wallet.

Specified by:
deserializeWalletExtension in interface WalletExtension
Throws:
Exception

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All rights reserved.