@Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { Iterator<TransactionOutput> iter = candidates.iterator(); while (iter.hasNext()) { TransactionOutput output = iter.next(); if (spent.contains(output.getOutPointFor())) iter.remove(); } return delegate.select(target, candidates); } }
@Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { Iterator<TransactionOutput> iter = candidates.iterator(); while (iter.hasNext()) { TransactionOutput output = iter.next(); if (spent.contains(output.getOutPointFor())) iter.remove(); } return delegate.select(target, candidates); } }
@Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { Iterator<TransactionOutput> iter = candidates.iterator(); while (iter.hasNext()) { TransactionOutput output = iter.next(); if (spent.contains(output.getOutPointFor())) iter.remove(); } return delegate.select(target, candidates); } }
@Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { Iterator<TransactionOutput> iter = candidates.iterator(); while (iter.hasNext()) { TransactionOutput output = iter.next(); if (spent.contains(output.getOutPointFor())) iter.remove(); } return delegate.select(target, candidates); } }
public static TrimmedOutPoint get(TransactionOutput txo) { return get(txo.getOutPointFor()); }
public static TrimmedOutPoint get(TransactionOutput txo) { return get(txo.getOutPointFor()); }
private void calcBloomOutPointsLocked() { // TODO: This could be done once and then kept up to date. bloomOutPoints.clear(); Set<Transaction> all = new HashSet<Transaction>(); all.addAll(unspent.values()); all.addAll(spent.values()); all.addAll(pending.values()); for (Transaction tx : all) { for (TransactionOutput out : tx.getOutputs()) { try { if (isTxOutputBloomFilterable(out)) bloomOutPoints.add(out.getOutPointFor()); } catch (ScriptException e) { // If it is ours, we parsed the script correctly, so this shouldn't happen. throw new RuntimeException(e); } } } }
private void calcBloomOutPointsLocked() { // TODO: This could be done once and then kept up to date. bloomOutPoints.clear(); Set<Transaction> all = new HashSet<>(); all.addAll(unspent.values()); all.addAll(spent.values()); all.addAll(pending.values()); for (Transaction tx : all) { for (TransactionOutput out : tx.getOutputs()) { try { if (isTxOutputBloomFilterable(out)) bloomOutPoints.add(out.getOutPointFor()); } catch (ScriptException e) { // If it is ours, we parsed the script correctly, so this shouldn't happen. throw new RuntimeException(e); } } } }
private void calcBloomOutPointsLocked() { // TODO: This could be done once and then kept up to date. bloomOutPoints.clear(); Set<Transaction> all = new HashSet<Transaction>(); all.addAll(unspent.values()); all.addAll(spent.values()); all.addAll(pending.values()); for (Transaction tx : all) { for (TransactionOutput out : tx.getOutputs()) { try { if (isTxOutputBloomFilterable(out)) bloomOutPoints.add(out.getOutPointFor()); } catch (ScriptException e) { // If it is ours, we parsed the script correctly, so this shouldn't happen. throw new RuntimeException(e); } } } }
/** * Adds an input that points to the given output and contains a valid signature for it, calculated using the * signing key. */ public TransactionInput addSignedInput(TransactionOutput output, ECKey signingKey) { return addSignedInput(output.getOutPointFor(), output.getScriptPubKey(), signingKey); }
/** * Adds an input that points to the given output and contains a valid signature for it, calculated using the * signing key. */ public TransactionInput addSignedInput(TransactionOutput output, ECKey signingKey) { return addSignedInput(output.getOutPointFor(), output.getScriptPubKey(), signingKey); }
/** * Adds an input that points to the given output and contains a valid signature for it, calculated using the * signing key. */ public TransactionInput addSignedInput(TransactionOutput output, ECKey signingKey, SigHash sigHash, boolean anyoneCanPay) { return addSignedInput(output.getOutPointFor(), output.getScriptPubKey(), signingKey, sigHash, anyoneCanPay); }
/** * Adds an input that points to the given output and contains a valid signature for it, calculated using the * signing key. */ public TransactionInput addSignedInput(TransactionOutput output, ECKey signingKey) { return addSignedInput(output.getOutPointFor(), output.getScriptPubKey(), signingKey); }
/** * Adds an input that points to the given output and contains a valid signature for it, calculated using the * signing key. */ public TransactionInput addSignedInput(TransactionOutput output, ECKey signingKey, SigHash sigHash, boolean anyoneCanPay) { return addSignedInput(output.getOutPointFor(), output.getScriptPubKey(), signingKey, sigHash, anyoneCanPay); }
/** * Adds an input that points to the given output and contains a valid signature for it, calculated using the * signing key. */ public TransactionInput addSignedInput( TransactionOutput output, ECKey signingKey, SigHash sigHash, boolean anyoneCanPay) { return addSignedInput(output.getOutPointFor(), output.getScriptPubKey(), signingKey, sigHash, anyoneCanPay); }
/** * Adds an input that points to the given output and contains a valid signature for it, calculated using the * signing key. */ public TransactionInput addSignedInput(TransactionOutput output, ECKey signingKey, SigHash sigHash, boolean anyoneCanPay) { return addSignedInput(output.getOutPointFor(), output.getScriptPubKey(), signingKey, sigHash, anyoneCanPay); }
/** * Adds an input that points to the given output and contains a valid signature for it, calculated using the * signing key. */ public TransactionInput addSignedInput(TransactionOutput output, ECKey signingKey) { return addSignedInput(output.getOutPointFor(), output.getScriptPubKey(), signingKey); }
private void sendEstablishMessageB () { Transaction channelTransaction = paymentLogic.getChannelTransaction( establishProgress.channel.anchorTx.getOutput(0).getOutPointFor(), establishProgress.channel.channelStatus.getCloneReversed(), establishProgress.channel.keyServer, establishProgress.channel.keyClient ); establishProgress.channel.channelSignatures = paymentLogic.getSignatureObject(establishProgress.channel, channelTransaction); LNEstablish message = messageFactory.getEstablishMessageB(establishProgress.channel.channelSignatures.channelSignatures.get(0)); establishProgress.messages.add(message); messageExecutor.sendMessageUpwards(message); }
@Test(expected = ScriptException.class) public void testAddSignedInputThrowsExceptionWhenScriptIsNotToRawPubKeyAndIsNotToAddress() { ECKey key = new ECKey(); Address addr = key.toAddress(PARAMS); Transaction fakeTx = FakeTxBuilder.createFakeTx(PARAMS, Coin.COIN, addr); Transaction tx = new Transaction(PARAMS); tx.addOutput(fakeTx.getOutput(0)); Script script = ScriptBuilder.createOpReturnScript(new byte[0]); tx.addSignedInput(fakeTx.getOutput(0).getOutPointFor(), script, key); }
/** * Ensure that hashForSignature() doesn't modify a transaction's data, which could wreak multithreading havoc. */ @Test public void testHashForSignatureThreadSafety() { Block genesis = UnitTestParams.get().getGenesisBlock(); Block block1 = genesis.createNextBlock(new ECKey().toAddress(UnitTestParams.get()), genesis.getTransactions().get(0).getOutput(0).getOutPointFor()); final Transaction tx = block1.getTransactions().get(1); final String txHash = tx.getHashAsString(); final String txNormalizedHash = tx.hashForSignature(0, new byte[0], Transaction.SigHash.ALL.byteValue()).toString(); for (int i = 0; i < 100; i++) { // ensure the transaction object itself was not modified; if it was, the hash will change assertEquals(txHash, tx.getHashAsString()); new Thread(){ public void run() { assertEquals(txNormalizedHash, tx.hashForSignature(0, new byte[0], Transaction.SigHash.ALL.byteValue()).toString()); } }; } }