public class PaymentChannelV1ServerState extends PaymentChannelServerState
PaymentChannelServerState.State| Modifier and Type | Field and Description |
|---|---|
protected ECKey |
clientKey |
bestValueSignature, bestValueToMe, broadcaster, contract, minExpireTime, serverKey, stateMachine, storedServerChannel| Constructor and Description |
|---|
PaymentChannelV1ServerState(TransactionBroadcaster broadcaster,
Wallet wallet,
ECKey serverKey,
long minExpireTime)
Creates a new state object to track the server side of a payment channel.
|
| Modifier and Type | Method and Description |
|---|---|
com.google.common.util.concurrent.ListenableFuture<Transaction> |
close(org.bouncycastle.crypto.params.KeyParameter userKey)
Closes this channel and broadcasts the highest value payment transaction on the network.
|
protected Script |
createOutputScript() |
protected ECKey |
getClientKey() |
TransactionOutput |
getClientOutput() |
Coin |
getFeePaid()
Gets the fee paid in the final payment transaction (only available if settle() did not throw an exception)
|
int |
getMajorVersion() |
long |
getRefundTransactionUnlockTime()
Gets the client's refund transaction which they can spend to get the entire channel value back if it reaches its
lock time.
|
protected Script |
getSignedScript()
Gets the script that signatures should sign against.
|
com.google.common.collect.Multimap<PaymentChannelServerState.State,PaymentChannelServerState.State> |
getStateTransitions() |
byte[] |
provideRefundTransaction(Transaction refundTx,
byte[] clientMultiSigPubKey)
Called when the client provides the refund transaction.
|
close, getBestValueToMe, getContract, getContractScript, getExpiryTime, getState, getTotalValue, incrementPayment, makeUnsignedChannelContract, provideContract, storeChannelInWallet, updateChannelInWallet, verifyContractprotected ECKey clientKey
public PaymentChannelV1ServerState(TransactionBroadcaster broadcaster, Wallet wallet, ECKey serverKey, long minExpireTime)
broadcaster - The peer group which we will broadcast transactions to, this should have multiple peerswallet - The wallet which will be used to complete transactionsserverKey - The private key which we use for our part of the multi-sig contract
(this MUST be fresh and CANNOT be used elsewhere)minExpireTime - The earliest time at which the client can claim the refund transaction (UNIX timestamp of block)public com.google.common.collect.Multimap<PaymentChannelServerState.State,PaymentChannelServerState.State> getStateTransitions()
getStateTransitions in class PaymentChannelServerStatepublic int getMajorVersion()
getMajorVersion in class PaymentChannelServerStatepublic TransactionOutput getClientOutput()
getClientOutput in class PaymentChannelServerStateprotected Script getSignedScript()
PaymentChannelServerStategetSignedScript in class PaymentChannelServerStatepublic byte[] provideRefundTransaction(Transaction refundTx, byte[] clientMultiSigPubKey) throws VerificationException
refundTx - The refund transaction, this object will be mutated when payment is incremented.clientMultiSigPubKey - The client's pubkey which is required for the multisig outputVerificationException - If the transaction isnt valid or did not meet the requirements of a refund transaction.protected Script createOutputScript()
createOutputScript in class PaymentChannelServerStateprotected ECKey getClientKey()
getClientKey in class PaymentChannelServerStatepublic com.google.common.util.concurrent.ListenableFuture<Transaction> close(@Nullable org.bouncycastle.crypto.params.KeyParameter userKey) throws InsufficientMoneyException
Closes this channel and broadcasts the highest value payment transaction on the network.
This will set the state to PaymentChannelServerState.State.CLOSED if the transaction is successfully broadcast on the network.
If we fail to broadcast for some reason, the state is set to PaymentChannelServerState.State.ERROR.
If the current state is before PaymentChannelServerState.State.READY (ie we have not finished initializing the channel), we
simply set the state to PaymentChannelServerState.State.CLOSED and let the client handle getting its refund transaction confirmed.
close in class PaymentChannelServerStateuserKey - The AES key to use for decryption of the private key. If null then no decryption is required.InsufficientMoneyException - If the payment tx would have cost more in fees to spend than it is worth.public Coin getFeePaid()
getFeePaid in class PaymentChannelServerStatepublic long getRefundTransactionUnlockTime()