3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 11:15:51 +00:00

Set newly created wallet transactions to have NOT_SEEN_IN_CHAIN confidence rather than UNKNOWN.

This commit is contained in:
Mike Hearn 2012-01-16 17:47:52 +01:00
parent e6612ad112
commit 3fa5c89b3e
2 changed files with 13 additions and 15 deletions

View File

@ -17,7 +17,6 @@
package com.google.bitcoin.core;
import com.google.bitcoin.core.WalletTransaction.Pool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -942,6 +941,7 @@ public class Wallet implements Serializable {
}
assert gathered.size() > 0;
Transaction sendTx = new Transaction(params);
sendTx.getConfidence().setConfidenceType(TransactionConfidence.ConfidenceType.NOT_SEEN_IN_CHAIN);
sendTx.addOutput(new TransactionOutput(params, sendTx, nanocoins, address));
BigInteger change = valueGathered.subtract(nanocoins);
if (change.compareTo(BigInteger.ZERO) > 0) {

View File

@ -16,23 +16,20 @@
package com.google.bitcoin.core;
import static com.google.bitcoin.core.TestUtils.createFakeBlock;
import static com.google.bitcoin.core.TestUtils.createFakeTx;
import static com.google.bitcoin.core.Utils.bitcoinValueToFriendlyString;
import static com.google.bitcoin.core.Utils.toNanoCoins;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.google.bitcoin.store.BlockStore;
import com.google.bitcoin.store.MemoryBlockStore;
import com.google.bitcoin.utils.BriefLogFormatter;
import org.junit.Before;
import org.junit.Test;
import java.math.BigInteger;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import com.google.bitcoin.store.BlockStore;
import com.google.bitcoin.store.MemoryBlockStore;
import com.google.bitcoin.utils.BriefLogFormatter;
import static com.google.bitcoin.core.TestUtils.createFakeBlock;
import static com.google.bitcoin.core.TestUtils.createFakeTx;
import static com.google.bitcoin.core.Utils.bitcoinValueToFriendlyString;
import static com.google.bitcoin.core.Utils.toNanoCoins;
import static org.junit.Assert.*;
public class WalletTest {
static final NetworkParameters params = NetworkParameters.unitTests();
@ -73,6 +70,7 @@ public class WalletTest {
// Do some basic sanity checks.
assertEquals(1, t2.getInputs().size());
assertEquals(myAddress, t2.getInputs().get(0).getScriptSig().getFromAddress());
assertEquals(t2.getConfidence().getConfidenceType(), TransactionConfidence.ConfidenceType.NOT_SEEN_IN_CHAIN);
// We have NOT proven that the signature is correct!
@ -350,7 +348,7 @@ public class WalletTest {
notifiedTx[0].getConfidence().getConfidenceType());
final Transaction t1Copy = new Transaction(params, t1.bitcoinSerialize());
wallet.receiveFromBlock(t1Copy, createFakeBlock(params, blockStore, t1Copy).storedBlock,
BlockChain.NewBlockType.BEST_CHAIN);
BlockChain.NewBlockType.BEST_CHAIN);
assertFalse(flags[0]);
assertTrue(flags[1]);
assertEquals(TransactionConfidence.ConfidenceType.BUILDING, notifiedTx[0].getConfidence().getConfidenceType());