Refactor tx handling

This commit is contained in:
Manfred Karrer 2015-03-16 09:57:21 +01:00
parent ca32014f8b
commit 25ff3d26f1
3 changed files with 23 additions and 22 deletions

View File

@ -370,7 +370,7 @@ public class WalletService {
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
mergedOutputs.stream().filter(e -> e.getScriptPubKey().isSentToAddress() ||
e.getScriptPubKey().isSentToP2SH()).forEach(transactionOutput -> {
e.getScriptPubKey().isPayToScriptHash()).forEach(transactionOutput -> {
Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params);
if (address.equals(outputAddress)) {
transactionConfidenceList.add(tx.getConfidence());
@ -440,12 +440,10 @@ public class WalletService {
private Coin getBalance(LinkedList<TransactionOutput> transactionOutputs, Address address) {
Coin balance = Coin.ZERO;
for (TransactionOutput transactionOutput : transactionOutputs) {
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey()
.isSentToP2SH()) {
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isPayToScriptHash()) {
Address addressOutput = transactionOutput.getScriptPubKey().getToAddress(params);
if (addressOutput.equals(address)) {
if (addressOutput.equals(address))
balance = balance.add(transactionOutput.getValue());
}
}
}
return balance;
@ -795,7 +793,7 @@ public class WalletService {
verifyTransaction(depositTx);
checkWalletConsistency();
checkScriptSigForAllInputs(depositTx);
//checkScriptSigForAllInputs(depositTx);
// Broadcast depositTx
log.trace("Wallet balance before broadcastTransaction: " + wallet.getBalance());
@ -1017,9 +1015,8 @@ public class WalletService {
private void checkScriptSig(Transaction transaction, TransactionInput input, int inputIndex) throws TransactionVerificationException {
try {
log.trace("Verifies that this script (interpreted as a scriptSig) correctly spends the given scriptPubKey.");
log.trace("Verifies that this script (interpreted as a scriptSig) correctly spends the given scriptPubKey. Check input at index: " + inputIndex);
input.getScriptSig().correctlySpends(transaction, inputIndex, input.getConnectedOutput().getScriptPubKey());
inputIndex++;
} catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
@ -1027,12 +1024,13 @@ public class WalletService {
}
}
private void checkScriptSigForAllInputs(Transaction transaction) throws TransactionVerificationException {
/*private void checkScriptSigForAllInputs(Transaction transaction) throws TransactionVerificationException {
int inputIndex = 0;
for (TransactionInput input : transaction.getInputs()) {
checkScriptSig(transaction, input, inputIndex);
inputIndex++;
}
}
}*/
private void removeSignatures(Transaction transaction) throws InsufficientMoneyException {
for (TransactionInput input : transaction.getInputs()) {

View File

@ -213,6 +213,7 @@ public class TradeManager {
case OPEN:
break;
case OFFERER_ACCEPTED:
case TAKE_OFFER_FEE_PAID:
case DEPOSIT_PUBLISHED:
case DEPOSIT_CONFIRMED:
case FIAT_PAYMENT_STARTED:

View File

@ -29,17 +29,21 @@
</root>
<logger name="io.bitsquare" level="TRACE"/>
<logger name="io.bitsquare.network.tomp2p.BootstrappedPeerBuilder" level="ERROR"/>
<logger name="io.bitsquare.gui.util.Profiler" level="ERROR"/>
<logger name="io.bitsquare.persistence.Persistence" level="ERROR"/>
<logger name="io.bitsquare.locale.BSResources" level="ERROR"/>
<logger name="org.bitcoinj" level="TRACE"/>
<logger name="org.bitcoinj" level="DEBUG"/>
<logger name="net.tomp2p" level="ERROR"/>
<logger name="com.vinumeris.updatefx" level="OFF"/>
<logger name="io.netty" level="OFF"/>
<logger name="org.bitcoinj.core.BitcoinSerializer" level="ERROR"/>
<logger name="org.bitcoinj.core.Peer" level="ERROR"/>
<logger name="org.bitcoinj.core.BitcoinSerializer" level="WARN"/>
<logger name="org.bitcoinj.core.Peer" level="WARN"/>
<!--
<logger name="com.vinumeris.updatefx" level="OFF"/>
<logger name="io.netty" level="OFF"/>
<logger name="org.bitcoinj.core.BitcoinSerializer" level="ERROR"/>
<logger name="org.bitcoinj.core.Peer" level="ERROR"/>-->
<!-- <logger name="net.tomp2p.message.Encoder" level="WARN"/>
<logger name="net.tomp2p.message.Decoder" level="WARN"/>
@ -51,11 +55,9 @@
<logger name="io.netty.buffer" level="WARN"/>-->
<!-- <logger name="org.bitcoinj.core.BitcoinSerializer" level="WARN"/>
<logger name="org.bitcoinj.core.AbstractBlockChain" level="WARN"/>
<logger name="org.bitcoinj.wallet.DeterministicKeyChain" level="WARN"/>-->
<!-- <logger name="org.bitcoinj.core.BitcoinSerializer" level="WARN"/>
<logger name="org.bitcoinj.core.AbstractBlockChain" level="WARN"/>
<logger name="org.bitcoinj.wallet.DeterministicKeyChain" level="WARN"/>-->
<!-- <logger name="io.bitsquare.btc.WalletService" level="WARN"/>-->
<!--