/** * Skips saving state in the wallet for testing */ @VisibleForTesting synchronized void fakeSave() { try { wallet.commitTx(getContractInternal()); } catch (VerificationException e) { throw new RuntimeException(e); // We created it } stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); }
/** * Skips saving state in the wallet for testing */ @VisibleForTesting synchronized void fakeSave() { try { wallet.commitTx(getContractInternal()); } catch (VerificationException e) { throw new RuntimeException(e); // We created it } stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); }
/** * Skips saving state in the wallet for testing */ @VisibleForTesting synchronized void fakeSave() { try { wallet.commitTx(getContractInternal()); } catch (VerificationException e) { throw new RuntimeException(e); // We created it } stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); }
/** * Skips saving state in the wallet for testing */ @VisibleForTesting synchronized void fakeSave() { try { wallet.commitTx(getContractInternal()); } catch (VerificationException e) { throw new RuntimeException(e); // We created it } stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); }
@Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { synchronized (PaymentChannelClientState.this) { if (getContractInternal() == null) return; if (isSettlementTransaction(tx)) { log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash()); // Record the fact that it was closed along with the transaction that closed it. stateMachine.transition(State.CLOSED); if (storedChannel == null) return; storedChannel.close = tx; updateChannelInWallet(); watchCloseConfirmations(); } } } });
@Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { synchronized (PaymentChannelClientState.this) { if (getContractInternal() == null) return; if (isSettlementTransaction(tx)) { log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash()); // Record the fact that it was closed along with the transaction that closed it. stateMachine.transition(State.CLOSED); if (storedChannel == null) return; storedChannel.close = tx; updateChannelInWallet(); watchCloseConfirmations(); } } } });
@Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { synchronized (PaymentChannelClientState.this) { if (getContractInternal() == null) return; if (isSettlementTransaction(tx)) { log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash()); // Record the fact that it was closed along with the transaction that closed it. stateMachine.transition(State.CLOSED); if (storedChannel == null) return; storedChannel.close = tx; updateChannelInWallet(); watchCloseConfirmations(); } } } });
@Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { synchronized (PaymentChannelClientState.this) { if (getContractInternal() == null) return; if (isSettlementTransaction(tx)) { log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash()); // Record the fact that it was closed along with the transaction that closed it. stateMachine.transition(State.CLOSED); if (storedChannel == null) return; storedChannel.close = tx; updateChannelInWallet(); watchCloseConfirmations(); } } } });
/** * Returns true if the tx is a valid settlement transaction. */ public synchronized boolean isSettlementTransaction(Transaction tx) { try { tx.verify(); tx.getInput(0).verify(getContractInternal().getOutput(0)); return true; } catch (VerificationException e) { return false; } }
/** * Returns true if the tx is a valid settlement transaction. */ public synchronized boolean isSettlementTransaction(Transaction tx) { try { tx.verify(); tx.getInput(0).verify(getContractInternal().getOutput(0)); return true; } catch (VerificationException e) { return false; } }
/** * Returns true if the tx is a valid settlement transaction. */ public synchronized boolean isSettlementTransaction(Transaction tx) { try { tx.verify(); tx.getInput(0).verify(getContractInternal().getOutput(0)); return true; } catch (VerificationException e) { return false; } }
/** * <p>Stores this channel's state in the wallet as a part of a {@link StoredPaymentChannelClientStates} wallet * extension and keeps it up-to-date each time payment is incremented. This allows the * {@link StoredPaymentChannelClientStates} object to keep track of timeouts and broadcast the refund transaction * when the channel expires.</p> * * <p>A channel may only be stored after it has fully opened (ie state == State.READY). The wallet provided in the * constructor must already have a {@link StoredPaymentChannelClientStates} object in its extensions set.</p> * * @param id A hash providing this channel with an id which uniquely identifies this server. It does not have to be * unique. */ public synchronized void storeChannelInWallet(Sha256Hash id) { stateMachine.checkState(State.SAVE_STATE_IN_WALLET); checkState(id != null); if (storedChannel != null) { checkState(storedChannel.id.equals(id)); return; } doStoreChannelInWallet(id); try { wallet.commitTx(getContractInternal()); } catch (VerificationException e) { throw new RuntimeException(e); // We created it } stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); }
/** * Returns true if the tx is a valid settlement transaction. */ public synchronized boolean isSettlementTransaction(Transaction tx) { try { tx.verify(); tx.getInput(0).verify(getContractInternal().getOutput(0)); return true; } catch (VerificationException e) { return false; } }
/** * <p>Stores this channel's state in the wallet as a part of a {@link StoredPaymentChannelClientStates} wallet * extension and keeps it up-to-date each time payment is incremented. This allows the * {@link StoredPaymentChannelClientStates} object to keep track of timeouts and broadcast the refund transaction * when the channel expires.</p> * * <p>A channel may only be stored after it has fully opened (ie state == State.READY). The wallet provided in the * constructor must already have a {@link StoredPaymentChannelClientStates} object in its extensions set.</p> * * @param id A hash providing this channel with an id which uniquely identifies this server. It does not have to be * unique. */ public synchronized void storeChannelInWallet(Sha256Hash id) { stateMachine.checkState(State.SAVE_STATE_IN_WALLET); checkState(id != null); if (storedChannel != null) { checkState(storedChannel.id.equals(id)); return; } doStoreChannelInWallet(id); try { wallet.commitTx(getContractInternal()); } catch (VerificationException e) { throw new RuntimeException(e); // We created it } stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); }
/** * <p>Stores this channel's state in the wallet as a part of a {@link StoredPaymentChannelClientStates} wallet * extension and keeps it up-to-date each time payment is incremented. This allows the * {@link StoredPaymentChannelClientStates} object to keep track of timeouts and broadcast the refund transaction * when the channel expires.</p> * * <p>A channel may only be stored after it has fully opened (ie state == State.READY). The wallet provided in the * constructor must already have a {@link StoredPaymentChannelClientStates} object in its extensions set.</p> * * @param id A hash providing this channel with an id which uniquely identifies this server. It does not have to be * unique. */ public synchronized void storeChannelInWallet(Sha256Hash id) { stateMachine.checkState(State.SAVE_STATE_IN_WALLET); checkState(id != null); if (storedChannel != null) { checkState(storedChannel.id.equals(id)); return; } doStoreChannelInWallet(id); try { wallet.commitTx(getContractInternal()); } catch (VerificationException e) { throw new RuntimeException(e); // We created it } stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); }
/** * <p>Stores this channel's state in the wallet as a part of a {@link StoredPaymentChannelClientStates} wallet * extension and keeps it up-to-date each time payment is incremented. This allows the * {@link StoredPaymentChannelClientStates} object to keep track of timeouts and broadcast the refund transaction * when the channel expires.</p> * * <p>A channel may only be stored after it has fully opened (ie state == State.READY). The wallet provided in the * constructor must already have a {@link StoredPaymentChannelClientStates} object in its extensions set.</p> * * @param id A hash providing this channel with an id which uniquely identifies this server. It does not have to be * unique. */ public synchronized void storeChannelInWallet(Sha256Hash id) { stateMachine.checkState(State.SAVE_STATE_IN_WALLET); checkState(id != null); if (storedChannel != null) { checkState(storedChannel.id.equals(id)); return; } doStoreChannelInWallet(id); try { wallet.commitTx(getContractInternal()); } catch (VerificationException e) { throw new RuntimeException(e); // We created it } stateMachine.transition(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); }
private synchronized Transaction makeUnsignedChannelContract(Coin valueToMe) throws ValueOutOfRangeException { Transaction tx = new Transaction(wallet.getParams()); tx.addInput(getContractInternal().getOutput(0)); // Our output always comes first. // TODO: We should drop myKey in favor of output key + multisig key separation // (as its always obvious who the client is based on T2 output order) tx.addOutput(valueToMe, myKey.toAddress(wallet.getParams())); return tx; }
private synchronized Transaction makeUnsignedChannelContract(Coin valueToMe) throws ValueOutOfRangeException { Transaction tx = new Transaction(wallet.getParams()); tx.addInput(getContractInternal().getOutput(0)); // Our output always comes first. // TODO: We should drop myKey in favor of output key + multisig key separation // (as its always obvious who the client is based on T2 output order) tx.addOutput(valueToMe, myKey.toAddress(wallet.getParams())); return tx; }
private synchronized Transaction makeUnsignedChannelContract(Coin valueToMe) throws ValueOutOfRangeException { Transaction tx = new Transaction(wallet.getParams()); tx.addInput(getContractInternal().getOutput(0)); // Our output always comes first. // TODO: We should drop myKey in favor of output key + multisig key separation // (as its always obvious who the client is based on T2 output order) tx.addOutput(valueToMe, myKey.toAddress(wallet.getParams())); return tx; }
private synchronized Transaction makeUnsignedChannelContract(Coin valueToMe) throws ValueOutOfRangeException { Transaction tx = new Transaction(wallet.getParams()); tx.addInput(getContractInternal().getOutput(0)); // Our output always comes first. // TODO: We should drop myKey in favor of output key + multisig key separation // (as its always obvious who the client is based on T2 output order) tx.addOutput(valueToMe, myKey.toAddress(wallet.getParams())); return tx; }