public interface IPaymentChannelClient
PaymentChannelClient
, but alternative implementations are possible. For example, an implementor might
send RPCs to a separate (locally installed or even remote) wallet app rather than implementing the algorithm locally.Modifier and Type | Interface and Description |
---|---|
static interface |
IPaymentChannelClient.ClientConnection
Implements the connection between this client and the server, providing an interface which allows messages to be
sent to the server, requests for the connection to the server to be closed, and a callback which occurs when the
channel is fully open.
|
static interface |
IPaymentChannelClient.Factory
An implementor of this interface creates payment channel clients that "talk back" with the given connection.
|
Modifier and Type | Method and Description |
---|---|
void |
connectionClosed()
Called when the connection to the server terminates.
|
void |
connectionOpen()
Called to indicate the connection has been opened and messages can now be generated for the server.
|
ListenableFuture<PaymentIncrementAck> |
incrementPayment(Coin size,
com.google.protobuf.ByteString info,
org.spongycastle.crypto.params.KeyParameter userKey)
Increments the total value which we pay the server.
|
void |
receiveMessage(Protos.TwoWayChannelMessage msg)
Called when a message is received from the server.
|
void |
settle()
Settles the channel, notifying the server it can broadcast the most recent payment transaction.
|
void receiveMessage(Protos.TwoWayChannelMessage msg) throws InsufficientMoneyException
InsufficientMoneyException
void connectionClosed()
Called when the connection to the server terminates.
For stateless protocols, this translates to a client not using the channel for the immediate future, but intending to reopen the channel later. There is likely little reason to use this in a stateless protocol.
Note that this MUST still be called even after either
PaymentChannelClient.ClientConnection#destroyConnection(org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason)
or
settle()
is called, to actually handle the connection close logic.
void settle() throws IllegalStateException
Settles the channel, notifying the server it can broadcast the most recent payment transaction.
Note that this only generates a CLOSE message for the server and calls
PaymentChannelClient.ClientConnection#destroyConnection(org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason)
to settle the connection, it does not actually handle connection close logic, and
PaymentChannelClient.connectionClosed()
must still be called after the connection fully settles.
IllegalStateException
- If the connection is not currently open (ie the CLOSE message cannot be sent)void connectionOpen()
Called to indicate the connection has been opened and messages can now be generated for the server.
Attempts to find a channel to resume and generates a CLIENT_VERSION message for the server based on the result.
ListenableFuture<PaymentIncrementAck> incrementPayment(Coin size, @Nullable com.google.protobuf.ByteString info, @Nullable org.spongycastle.crypto.params.KeyParameter userKey) throws ValueOutOfRangeException, IllegalStateException, ECKey.KeyIsEncryptedException
size
- How many satoshis to increment the payment by (note: not the new total).info
- Information about this update, used to extend this protocol.ValueOutOfRangeException
- If the size is negative or would pay more than this channel's total value
(PaymentChannelClientConnection.state()
.getTotalValue())IllegalStateException
- If the channel has been closed or is not yet open
(see PaymentChannelClientConnection.getChannelOpenFuture()
for the second)ECKey.KeyIsEncryptedException
- If the keys are encrypted and no AES key has been provided,Copyright © 2016. All rights reserved.