public class StoredPaymentChannelServerStates extends Object implements WalletExtension
StoredServerChannel
s and expires them 2 hours before their refund transactions
unlock.Modifier and Type | Field and Description |
---|---|
static long |
CHANNEL_EXPIRE_OFFSET
The offset between the refund transaction's lock time and the time channels will be automatically closed.
|
Constructor and Description |
---|
StoredPaymentChannelServerStates(Wallet wallet)
Creates a new PaymentChannelServerStateManager and associates it with the given
Wallet
Use this constructor if you use WalletAppKit, it will provide the broadcaster for you (no need to call the setter) |
StoredPaymentChannelServerStates(Wallet wallet,
TransactionBroadcaster broadcaster)
Creates a new PaymentChannelServerStateManager and associates it with the given
Wallet and
TransactionBroadcaster which are used to complete and announce payment transactions. |
Modifier and Type | Method and Description |
---|---|
void |
closeChannel(StoredServerChannel channel)
Closes the given channel using
ServerConnectionEventHandler.closeChannel() and
PaymentChannelV1ServerState.close() to notify any connected client of channel closure and to complete and
broadcast the latest payment transaction. |
void |
deserializeWalletExtension(Wallet containingWallet,
byte[] data)
Loads the contents of this object from the wallet.
|
StoredServerChannel |
getChannel(Sha256Hash id)
Gets the
StoredServerChannel with the given channel id (ie contract transaction hash). |
Map<Sha256Hash,StoredServerChannel> |
getChannelMap()
Get a copy of all
StoredServerChannel s |
static StoredPaymentChannelServerStates |
getFromWallet(Wallet wallet)
Returns this extension from the given wallet, or null if no such extension was added.
|
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.
|
void |
putChannel(StoredServerChannel channel)
Puts the given channel in the channels map and automatically closes it 2 hours before its refund transaction
becomes spendable.
|
byte[] |
serializeWalletExtension()
Returns bytes that will be saved in the wallet.
|
void |
setTransactionBroadcaster(TransactionBroadcaster broadcaster)
Use this setter if the broadcaster is not available during instantiation and you're not using WalletAppKit.
|
String |
toString() |
void |
updatedChannel(StoredServerChannel channel)
Notifies the set of stored states that a channel has been updated.
|
public static final long CHANNEL_EXPIRE_OFFSET
public StoredPaymentChannelServerStates(@Nullable Wallet wallet, TransactionBroadcaster broadcaster)
Wallet
and
TransactionBroadcaster
which are used to complete and announce payment transactions.public final void setTransactionBroadcaster(TransactionBroadcaster broadcaster)
broadcaster
- Used when the payment channels are closed@Nullable public static StoredPaymentChannelServerStates getFromWallet(Wallet wallet)
public void closeChannel(StoredServerChannel channel)
Closes the given channel using ServerConnectionEventHandler.closeChannel()
and
PaymentChannelV1ServerState.close()
to notify any connected client of channel closure and to complete and
broadcast the latest payment transaction.
Removes the given channel from this set of StoredServerChannel
s and notifies the wallet of a change to
this wallet extension.
public StoredServerChannel getChannel(Sha256Hash id)
StoredServerChannel
with the given channel id (ie contract transaction hash).public Map<Sha256Hash,StoredServerChannel> getChannelMap()
StoredServerChannel
spublic void updatedChannel(StoredServerChannel channel)
public void putChannel(StoredServerChannel channel)
Puts the given channel in the channels map and automatically closes it 2 hours before its refund transaction becomes spendable.
Because there must be only one, canonical StoredServerChannel
per channel, this method throws if the
channel is already present in the set of channels.
public String getWalletExtensionID()
WalletExtension
getWalletExtensionID
in interface WalletExtension
public boolean isWalletExtensionMandatory()
WalletExtension
isWalletExtensionMandatory
in interface WalletExtension
public byte[] serializeWalletExtension()
WalletExtension
serializeWalletExtension
in interface WalletExtension
public void deserializeWalletExtension(Wallet containingWallet, byte[] data) throws Exception
WalletExtension
deserializeWalletExtension
in interface WalletExtension
Exception
Copyright © 2016. All rights reserved.