Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Wallet
bitcoinj
Commits
13a2c80f
Commit
13a2c80f
authored
Sep 30, 2017
by
T Dev. D
😎
Browse files
move ScriptException to package 'script'
parent
a1df4694
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
40 additions
and
32 deletions
+40
-32
core/src/main/java/org/bitcoinj/core/AbstractBlockChain.java
core/src/main/java/org/bitcoinj/core/AbstractBlockChain.java
+18
-17
core/src/main/java/org/bitcoinj/core/Transaction.java
core/src/main/java/org/bitcoinj/core/Transaction.java
+2
-1
core/src/main/java/org/bitcoinj/core/TransactionInput.java
core/src/main/java/org/bitcoinj/core/TransactionInput.java
+3
-2
core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelV1ClientState.java
...coinj/protocols/channels/PaymentChannelV1ClientState.java
+1
-0
core/src/main/java/org/bitcoinj/script/ScriptException.java
core/src/main/java/org/bitcoinj/script/ScriptException.java
+3
-1
core/src/main/java/org/bitcoinj/signers/CustomTransactionSigner.java
...in/java/org/bitcoinj/signers/CustomTransactionSigner.java
+1
-2
core/src/main/java/org/bitcoinj/signers/LocalTransactionSigner.java
...ain/java/org/bitcoinj/signers/LocalTransactionSigner.java
+1
-1
core/src/main/java/org/bitcoinj/store/LevelDBBlockStore.java
core/src/main/java/org/bitcoinj/store/LevelDBBlockStore.java
+2
-1
core/src/main/java/org/bitcoinj/store/LevelDBFullPrunedBlockStore.java
.../java/org/bitcoinj/store/LevelDBFullPrunedBlockStore.java
+2
-2
core/src/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java
...rc/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java
+1
-0
core/src/main/java/org/bitcoinj/wallet/Wallet.java
core/src/main/java/org/bitcoinj/wallet/Wallet.java
+3
-4
core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java
...in/java/org/bitcoinj/wallet/WalletProtobufSerializer.java
+1
-0
core/src/test/java/org/bitcoinj/core/FullBlockTestGenerator.java
...c/test/java/org/bitcoinj/core/FullBlockTestGenerator.java
+2
-1
No files found.
core/src/main/java/org/bitcoinj/core/AbstractBlockChain.java
View file @
13a2c80f
...
...
@@ -21,6 +21,7 @@ import com.google.common.base.*;
import
com.google.common.collect.*
;
import
com.google.common.util.concurrent.*
;
import
org.bitcoinj.core.listeners.*
;
import
org.bitcoinj.script.ScriptException
;
import
org.bitcoinj.store.*
;
import
org.bitcoinj.utils.*
;
import
org.bitcoinj.wallet.Wallet
;
...
...
@@ -281,14 +282,14 @@ public abstract class AbstractBlockChain {
public
void
removeTransactionReceivedListener
(
TransactionReceivedInBlockListener
listener
)
{
ListenerRegistration
.
removeFromList
(
listener
,
transactionReceivedListeners
);
}
/**
* Returns the {@link BlockStore} the chain was constructed with. You can use this to iterate over the chain.
*/
public
BlockStore
getBlockStore
()
{
return
blockStore
;
}
/**
* Adds/updates the given {@link Block} with the block store.
* This version is used when the transactions have not been verified.
...
...
@@ -298,7 +299,7 @@ public abstract class AbstractBlockChain {
*/
protected
abstract
StoredBlock
addToBlockStore
(
StoredBlock
storedPrev
,
Block
block
)
throws
BlockStoreException
,
VerificationException
;
/**
* Adds/updates the given {@link StoredBlock} with the block store.
* This version is used when the transactions have already been verified to properly spend txOutputChanges.
...
...
@@ -314,7 +315,7 @@ public abstract class AbstractBlockChain {
/**
* Rollback the block store to a given height. This is currently only supported by {@link BlockChain} instances.
*
*
* @throws BlockStoreException
* if the operation fails or is unsupported.
*/
...
...
@@ -326,7 +327,7 @@ public abstract class AbstractBlockChain {
* that were started by disconnectTransactions/connectTransactions.
*/
protected
abstract
void
doSetChainHead
(
StoredBlock
chainHead
)
throws
BlockStoreException
;
/**
* Called if we (possibly) previously called disconnectTransaction/connectTransactions,
* but will not be calling preSetChainHead as a block failed verification.
...
...
@@ -334,7 +335,7 @@ public abstract class AbstractBlockChain {
* disconnectTransactions/connectTransactions.
*/
protected
abstract
void
notSettingChainHead
()
throws
BlockStoreException
;
/**
* For a standard BlockChain, this should return blockStore.get(hash),
* for a FullPrunedBlockChain blockStore.getOnceUndoableStoredBlock(hash)
...
...
@@ -363,7 +364,7 @@ public abstract class AbstractBlockChain {
block
.
toString
(),
e
);
}
}
/**
* Processes a received block and tries to add it to the chain. If there's something wrong with the block an
* exception is thrown. If the block is OK but cannot be connected to the chain at this time, returns false.
...
...
@@ -392,13 +393,13 @@ public abstract class AbstractBlockChain {
block
.
toString
(),
e
);
}
}
/**
* Whether or not we are maintaining a set of unspent outputs and are verifying all transactions.
* Also indicates that all calls to add() should provide a block containing transactions
*/
protected
abstract
boolean
shouldVerifyTransactions
();
/**
* Connect each transaction in block.transactions, verifying them as we go and removing spent outputs
* If an error is encountered in a transaction, no changes should be made to the underlying BlockStore.
...
...
@@ -419,8 +420,8 @@ public abstract class AbstractBlockChain {
* @throws BlockStoreException if the block store had an underlying error or newBlock does not exist in the block store at all.
* @return The full set of all changes made to the set of open transaction outputs.
*/
protected
abstract
TransactionOutputChanges
connectTransactions
(
StoredBlock
newBlock
)
throws
VerificationException
,
BlockStoreException
,
PrunedException
;
protected
abstract
TransactionOutputChanges
connectTransactions
(
StoredBlock
newBlock
)
throws
VerificationException
,
BlockStoreException
,
PrunedException
;
// filteredTxHashList contains all transactions, filteredTxn just a subset
private
boolean
add
(
Block
block
,
boolean
tryConnecting
,
@Nullable
List
<
Sha256Hash
>
filteredTxHashList
,
@Nullable
Map
<
Sha256Hash
,
Transaction
>
filteredTxn
)
...
...
@@ -531,7 +532,7 @@ public abstract class AbstractBlockChain {
if
(!
tx
.
isFinal
(
storedPrev
.
getHeight
()
+
1
,
block
.
getTimeSeconds
()))
throw
new
VerificationException
(
"Block contains non-final transaction"
);
}
StoredBlock
head
=
getChainHead
();
if
(
storedPrev
.
equals
(
head
))
{
if
(
filtered
&&
filteredTxn
.
size
()
>
0
)
{
...
...
@@ -598,14 +599,14 @@ public abstract class AbstractBlockChain {
splitPointHeight
,
splitPointHash
,
newBlock
.
getHeader
().
getHashAsString
());
}
}
// We may not have any transactions if we received only a header, which can happen during fast catchup.
// If we do, send them to the wallet but state that they are on a side chain so it knows not to try and
// spend them until they become activated.
if
(
block
.
transactions
!=
null
||
filtered
)
{
informListenersForNewBlock
(
block
,
NewBlockType
.
SIDE_CHAIN
,
filteredTxHashList
,
filteredTxn
,
newBlock
);
}
if
(
haveNewBestChain
)
handleNewBestChain
(
storedPrev
,
newBlock
,
block
,
expensiveChecks
);
}
...
...
@@ -721,11 +722,11 @@ public abstract class AbstractBlockChain {
timestamps
[
10
]
=
storedBlock
.
getHeader
().
getTimeSeconds
();
while
(
unused
>=
0
&&
(
storedBlock
=
storedBlock
.
getPrev
(
store
))
!=
null
)
timestamps
[
unused
--]
=
storedBlock
.
getHeader
().
getTimeSeconds
();
Arrays
.
sort
(
timestamps
,
unused
+
1
,
11
);
return
timestamps
[
unused
+
(
11
-
unused
)/
2
];
}
/**
* Disconnect each transaction in the block (after reading it from the block store)
* Only called if(shouldVerifyTransactions())
...
...
@@ -736,7 +737,7 @@ public abstract class AbstractBlockChain {
/**
* Called as part of connecting a block when the new block results in a different chain having higher total work.
*
*
* if (shouldVerifyTransactions)
* Either newChainHead needs to be in the block store as a FullStoredBlock, or (block != null && block.transactions != null)
*/
...
...
core/src/main/java/org/bitcoinj/core/Transaction.java
View file @
13a2c80f
...
...
@@ -21,6 +21,7 @@ import org.bitcoinj.core.TransactionConfidence.ConfidenceType;
import
org.bitcoinj.crypto.TransactionSignature
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptBuilder
;
import
org.bitcoinj.script.ScriptException
;
import
org.bitcoinj.script.ScriptOpCodes
;
import
org.bitcoinj.signers.TransactionSigner
;
import
org.bitcoinj.utils.ExchangeRate
;
...
...
@@ -56,7 +57,7 @@ import java.math.BigInteger;
* Whether to trust a transaction is something that needs to be decided on a case by case basis - a rule that makes
* sense for selling MP3s might not make sense for selling cars, or accepting payments from a family member. If you
* are building a wallet, how to present confidence to your users is something to consider carefully.</p>
*
*
* <p>Instances of this class are not safe for use by multiple threads.</p>
*/
public
class
Transaction
extends
ChildMessage
{
...
...
core/src/main/java/org/bitcoinj/core/TransactionInput.java
View file @
13a2c80f
...
...
@@ -18,6 +18,7 @@
package
org.bitcoinj.core
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptException
;
import
org.bitcoinj.wallet.DefaultRiskAnalysis
;
import
org.bitcoinj.wallet.KeyBag
;
import
org.bitcoinj.wallet.RedeemData
;
...
...
@@ -40,7 +41,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
* can be claimed by the recipient in the input of another transaction. You can imagine a
* transaction as being a module which is wired up to others, the inputs of one have to be wired
* to the outputs of another. The exceptions are coinbase transactions, which create new coins.</p>
*
*
* <p>Instances of this class are not safe for use by multiple threads.</p>
*/
public
class
TransactionInput
extends
ChildMessage
{
...
...
@@ -213,7 +214,7 @@ public class TransactionInput extends ChildMessage {
}
/**
* @return The previous output transaction reference, as an OutPoint structure. This contains the
* @return The previous output transaction reference, as an OutPoint structure. This contains the
* data needed to connect to the output of the transaction we're gathering coins from.
*/
public
TransactionOutPoint
getOutpoint
()
{
...
...
core/src/main/java/org/bitcoinj/protocols/channels/PaymentChannelV1ClientState.java
View file @
13a2c80f
...
...
@@ -23,6 +23,7 @@ import org.bitcoinj.crypto.TransactionSignature;
import
org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientChannelProperties
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptBuilder
;
import
org.bitcoinj.script.ScriptException
;
import
org.bitcoinj.wallet.AllowUnconfirmedCoinSelector
;
import
org.bitcoinj.wallet.SendRequest
;
import
org.bitcoinj.wallet.Wallet
;
...
...
core/src/main/java/org/bitcoinj/
core
/ScriptException.java
→
core/src/main/java/org/bitcoinj/
script
/ScriptException.java
View file @
13a2c80f
...
...
@@ -14,7 +14,9 @@
* limitations under the License.
*/
package
org.bitcoinj.core
;
package
org.bitcoinj.script
;
import
org.bitcoinj.core.VerificationException
;
@SuppressWarnings
(
"serial"
)
public
class
ScriptException
extends
VerificationException
{
...
...
core/src/main/java/org/bitcoinj/signers/CustomTransactionSigner.java
View file @
13a2c80f
...
...
@@ -20,6 +20,7 @@ import org.bitcoinj.core.*;
import
org.bitcoinj.crypto.ChildNumber
;
import
org.bitcoinj.crypto.TransactionSignature
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptException
;
import
org.bitcoinj.wallet.KeyBag
;
import
org.bitcoinj.wallet.RedeemData
;
import
org.slf4j.Logger
;
...
...
@@ -104,5 +105,3 @@ public abstract class CustomTransactionSigner extends StatelessTransactionSigner
}
}
core/src/main/java/org/bitcoinj/signers/LocalTransactionSigner.java
View file @
13a2c80f
...
...
@@ -18,12 +18,12 @@ package org.bitcoinj.signers;
import
java.util.EnumSet
;
import
org.bitcoinj.core.ECKey
;
import
org.bitcoinj.core.ScriptException
;
import
org.bitcoinj.core.Transaction
;
import
org.bitcoinj.core.TransactionInput
;
import
org.bitcoinj.crypto.DeterministicKey
;
import
org.bitcoinj.crypto.TransactionSignature
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptException
;
import
org.bitcoinj.script.Script.VerifyFlag
;
import
org.bitcoinj.wallet.KeyBag
;
import
org.bitcoinj.wallet.RedeemData
;
...
...
core/src/main/java/org/bitcoinj/store/LevelDBBlockStore.java
View file @
13a2c80f
/*
* Copyright by the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -17,6 +17,7 @@
package
org.bitcoinj.store
;
import
org.bitcoinj.core.*
;
import
org.bitcoinj.script.ScriptException
;
import
org.fusesource.leveldbjni.*
;
import
org.iq80.leveldb.*
;
...
...
core/src/main/java/org/bitcoinj/store/LevelDBFullPrunedBlockStore.java
View file @
13a2c80f
...
...
@@ -31,7 +31,6 @@ import java.nio.ByteBuffer;
import
org.bitcoinj.core.Address
;
import
org.bitcoinj.core.AddressFormatException
;
import
org.bitcoinj.core.NetworkParameters
;
import
org.bitcoinj.core.ScriptException
;
import
org.bitcoinj.core.Sha256Hash
;
import
org.bitcoinj.core.StoredBlock
;
import
org.bitcoinj.core.StoredUndoableBlock
;
...
...
@@ -41,6 +40,7 @@ import org.bitcoinj.core.UTXO;
import
org.bitcoinj.core.UTXOProviderException
;
import
org.bitcoinj.core.VerificationException
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptException
;
import
org.iq80.leveldb.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -54,7 +54,7 @@ import com.google.common.collect.Lists;
* <p>
* An implementation of a Fully Pruned Block Store using a leveldb implementation as the backing data store.
* <p>
*
*
* <p>
* Includes number of caches to optimise the initial blockchain download.
* </p>
...
...
core/src/main/java/org/bitcoinj/wallet/KeyTimeCoinSelector.java
View file @
13a2c80f
...
...
@@ -18,6 +18,7 @@ package org.bitcoinj.wallet;
import
org.bitcoinj.core.*
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptException
;
import
com.google.common.collect.Lists
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
core/src/main/java/org/bitcoinj/wallet/Wallet.java
View file @
13a2c80f
...
...
@@ -40,7 +40,6 @@ import org.bitcoinj.core.NetworkParameters;
import
org.bitcoinj.core.Peer
;
import
org.bitcoinj.core.PeerFilterProvider
;
import
org.bitcoinj.core.PeerGroup
;
import
org.bitcoinj.core.ScriptException
;
import
org.bitcoinj.core.Sha256Hash
;
import
org.bitcoinj.core.StoredBlock
;
import
org.bitcoinj.core.Transaction
;
...
...
@@ -816,7 +815,7 @@ public class Wallet extends BaseTaggableObject
/**
* Returns whether this wallet consists entirely of watching keys (unencrypted keys with no private part). Mixed
* wallets are forbidden.
*
*
* @throws IllegalStateException
* if there are no keys, or if there is a mix between watching and non-watching keys.
*/
...
...
@@ -4646,10 +4645,10 @@ public class Wallet extends BaseTaggableObject
* <p>Gets a bloom filter that contains all of the public keys from this wallet, and which will provide the given
* false-positive rate if it has size elements. Keep in mind that you will get 2 elements in the bloom filter for
* each key in the wallet, for the public key and the hash of the public key (address form).</p>
*
*
* <p>This is used to generate a BloomFilter which can be {@link BloomFilter#merge(BloomFilter)}d with another.
* It could also be used if you have a specific target for the filter's size.</p>
*
*
* <p>See the docs for {@link BloomFilter(int, double)} for a brief explanation of anonymity when using bloom
* filters.</p>
*/
...
...
core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java
View file @
13a2c80f
...
...
@@ -22,6 +22,7 @@ import org.bitcoinj.core.TransactionConfidence.ConfidenceType;
import
org.bitcoinj.crypto.KeyCrypter
;
import
org.bitcoinj.crypto.KeyCrypterScrypt
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptException
;
import
org.bitcoinj.signers.LocalTransactionSigner
;
import
org.bitcoinj.signers.TransactionSigner
;
import
org.bitcoinj.utils.ExchangeRate
;
...
...
core/src/test/java/org/bitcoinj/core/FullBlockTestGenerator.java
View file @
13a2c80f
/*
* Copyright by the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -22,6 +22,7 @@ import org.bitcoinj.core.Transaction.SigHash;
import
org.bitcoinj.crypto.TransactionSignature
;
import
org.bitcoinj.script.Script
;
import
org.bitcoinj.script.ScriptBuilder
;
import
org.bitcoinj.script.ScriptException
;
import
com.google.common.base.Preconditions
;
import
javax.annotation.Nullable
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment