3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 15:22:16 +00:00
Commit Graph

1445 Commits

Author SHA1 Message Date
Andreas Schildbach
70ce114d8e Fix link in Wallet.notifyTransactionIsInBlock() JavaDoc. 2014-06-10 12:04:20 +02:00
Andreas Schildbach
b9dd0a5417 Fix Wallet.checkForDoubleSpendAgainstPending() JavaDoc. It returns a boolean. 2014-06-10 12:04:20 +02:00
Andreas Schildbach
ffaf18fa94 Fix Wallet.isTransactionRelevant() JavaDoc. There is no "includeDoubleSpending". 2014-06-10 12:04:20 +02:00
Andreas Schildbach
8fde2de992 Remove undocumented and unused Transaction constructor. I found it misleading because it allows you to pass in a hash, but the hash can be changed without notice. 2014-06-09 12:59:51 +02:00
Harald Hoyer
a690454be1 Wallet: rename setLookaheadThreshold() to setKeychainLookaheadThreshold()
for consistency
2014-06-05 11:36:46 +08:00
Piotr Włodarek
2d9ad0466a Minor refactorings and fixes in VersionMessage.
* Fixed toString() bug.
* Updated comments to match present Bitcoin Core behavior with respect to User-Agent.
* Removed constructor accepting a boolean. This changes public API but neither multibit
  nor bitcoin-wallet nor mycelium nor hive-android uses this version of constructor.
  The rationale is to avoid passing a boolean to a method as this makes code hard to read.
  Client classes updated to preserve original semantic. All tests pass.
2014-06-05 11:32:53 +08:00
Andreas Schildbach
31af80ccd3 CoinFormat class, for formatting and parsing coin values to and from human readable form. 2014-06-05 11:25:06 +08:00
Harald Hoyer
384be446ce FullPrunedBlockChain: fixed typo
s/rage/range/g
2014-06-04 22:55:36 +08:00
Mike Hearn
86c5449ba2 Clarify BlockChainListener javadocs a bit. 2014-06-04 18:11:17 +08:00
Piotr Włodarek
21b3c06878 Breaks dependency cycle between Script.<clinit>, Script.<init> and NetworkParamenters.<init>. Resolves issue #549.
Script.<clinit> depended both on Script.<init> and NetworkParameters.<init> to prepare ScriptChunk cache.

At the same time NetworkParameters.<init> depended on Script.<clinit> by using Script.writeBytes().

The fix frees Script.<clinit> from both the NetworkParameters and Script objects.

This should remove the root cause behind NetworkParameters construction not being thread safe.
2014-06-02 20:49:36 +02:00
Kalpesh Parmar
4e568354be Arbitrary number of key creation (batch)
Functionality added to create keys in batch (any arbitary number),
previously keys  were created/returned one at a time.
2014-06-02 21:47:49 +08:00
Andreas Schildbach
638e921e53 Migrate usages of spongycastle Hex.encode/decode to Utils.HEX.encode/decode(), which in turn uses Guava's Base16 encoding. 2014-06-02 21:37:43 +08:00
Andreas Schildbach
da868973df Migrate usages of Utils.bytesToHexString() to Utils.HEX.encode(), which in turn uses Guava's Base16 encoding. 2014-06-02 21:37:43 +08:00
Piotr Włodarek
7f84603e11 Renamed 'bytes', 'msg' to 'payload' in all Message classes.
* This is intended to clarify distinction between full message and its payload to match terminology advertised on https://en.bitcoin.it/wiki/Protocol_specification.
* Does not change public API.
* These refactorings were mostly automated and should not introduce bugs. All tests pass.
2014-06-02 21:29:04 +08:00
Piotr Włodarek
a95c2ed826 Minor comments improvements in Message, EmptyMessage and NetworkParameters. 2014-06-02 21:29:04 +08:00
Piotr Włodarek
019f5f846d Regenerate protobuf bindings. They didn't fully survive our refactorings. 2014-06-02 21:16:51 +08:00
troggy
eae64a5357 Wallet now delegates currentAddress/freshAddress calls to KeychainGroup
This way it's possible for KCG to yield P2H addresses in future
2014-06-02 21:15:58 +08:00
Andreas Schildbach
927d8514f5 Rename Coin.NANOCOIN to Coin.MICROCOIN. 2014-06-02 08:11:03 +02:00
Andreas Schildbach
fa63c83888 Fix 'java.math.Coin' in the JavaDocs. 2014-05-31 11:27:19 +02:00
Andreas Schildbach
346e8fb3bf Access NetworkParameters.MAX_MONEY in a static way. 2014-05-31 11:27:19 +02:00
Andreas Schildbach
39586bf515 Replace or remove remaining misuses of the term 'nanocoin'. 2014-05-30 18:09:36 +02:00
Andreas Schildbach
56ef72f36f Deprecate Coin.longValue() in favour of accessing Coin.value directly. 2014-05-30 18:09:36 +02:00
Andreas Schildbach
b15dbfb836 Remove unused imports. 2014-05-30 15:33:58 +02:00
Andreas Schildbach
f10fefe2ae Clear a lot of compiler warnings because of unparameterized types. 2014-05-30 15:33:58 +02:00
Andreas Schildbach
d4c1a1b043 Add missing @Override annotations. 2014-05-30 15:33:58 +02:00
Andreas Schildbach
51c48bb69f Clean up coin constants and make more use of it. 2014-05-30 15:09:33 +02:00
Andreas Schildbach
938dec7a73 Rename Coin.toNanoCoins(coins, cents) to Coin.valueOf(coins, cents). 2014-05-30 15:09:33 +02:00
Andreas Schildbach
49adaeed16 Rename Coin.toNanoCoin(String) to Coin.parseCoin(String). 2014-05-30 15:09:33 +02:00
Andreas Schildbach
3e846901cb Remove weird value accessors. 2014-05-30 15:09:33 +02:00
Andreas Schildbach
ee4dec1835 Remove weird constructors. 2014-05-30 15:09:32 +02:00
Andreas Schildbach
48a76a8a03 Clean up Coin API for multiplications and divisions. 2014-05-30 15:09:32 +02:00
Andreas Schildbach
eb81b0c815 Move coin related methods and constants from Utils into Coin. 2014-05-30 15:09:32 +02:00
Andreas Schildbach
e2140c5cf8 Refactor internal coin representation from BigInteger to long. 2014-05-30 15:09:32 +02:00
Andreas Schildbach
022e7c27fe Wrap coin-ish BigIntegers into Coin class. 2014-05-30 15:09:32 +02:00
troggy
d2e1b14d4c Wallet: add convenience methods to vend Address objects for currentKey/freshKey 2014-05-29 20:20:44 +02:00
Mike Hearn
c63f5f7553 Fix bugs and misc review comments from Harold Hoyer's key lookahead pull request. Still needed: unit tests. 2014-05-29 20:11:17 +02:00
Harald Hoyer
5726b97f70 HD Wallets: mark the DeterministicKeys as issued, if seen in a Transaction
If a Transaction contains a DeterministicKey of our
DeterministicKeyChains, then we should mark this key as issued. This can
happen, when we replay/resync the blockchain or when another device uses
one of our keys.

Signed-off-by: Harald Hoyer <harald@harald-hoyer.de>
2014-05-29 20:11:17 +02:00
Harald Hoyer
534a1e3a5c HD Wallets: add a threshold for the DeterministicKey lookahead
DeterministicKeyChain.maybeLookAhead() would pre-generate a new key, for
every issued key, even if it is only one. If we replay the blockchain
and update the issuedKeys counter, maybeLookAhead() would trigger the
regeneration and resending of the bloom filter for every used key.

This patch adds a threshold, where keys are only pre-generated after
more keys are needed than the value of the threshold.

Signed-off-by: Harald Hoyer <harald@harald-hoyer.de>
2014-05-29 20:11:17 +02:00
Mike Hearn
42bfbb9b1c Add some Javadocs and clean up the watching key API a tiny bit. Default creation time is now BIP32 standardisation time. 2014-05-29 20:11:17 +02:00
Harald Hoyer
9ff7a91c8c HD Wallets: let you specify the creation time for a WatchingKey
If the creation time for a WatchingKey is known, it should be taken into
account and stored.

Signed-off-by: Harald Hoyer <harald@harald-hoyer.de>
2014-05-29 20:11:17 +02:00
Mike Hearn
960b9d686e KeyChainGroup: defensive copy of the chains list in the c'tor 2014-05-29 20:11:16 +02:00
Mike Hearn
1628bf6329 WalletAppKit: set max connections to size of set peer addresses so localhost broadcast works. 2014-05-29 20:11:16 +02:00
Mike Hearn
e4af9a673f Tweaks to allow wallet subclasses to add their own extensions in their c'tors. 2014-05-29 20:11:16 +02:00
Mike Hearn
748ff6fc8e WalletAppKit: allow control of wallet construction. 2014-05-29 20:11:16 +02:00
Mike Hearn
4504633fd5 ECKey.recoverFromSignature: respect the compressed flag again. 2014-05-29 20:11:16 +02:00
Mike Hearn
d2837e8ea9 Wallet: allow customization of the wallet type that is deserialized. Makes subclassing Wallet more useful. 2014-05-29 20:11:16 +02:00
Mike Hearn
b374ba5108 HDW: Fix a decryption bug where we were (again) accidentally relying on padding checks to detect wrong passwords. Check the watching key derives correctly to fix. 2014-05-29 20:11:16 +02:00
Mike Hearn
24e41f01c6 Refactorings.
Make a convenience ECKey.decrypt(KeyParameter) that doesn't require the keycrypter to be manually specified, as often (always?) the key knows it already.

Introduce a KeyBag interface that just contains findKeyBy* methods, then make Wallet implement it and change Transaction.signInputs to use it. Take out the encrypted-key specific stuff here: Transaction now requires unencrypted keys. Create a DecryptingKeyBag class that just forwards calls to Wallet and decrypts the returned keys. This decouples the signing code from Wallet a bit.

Should be all API compatible.
2014-05-29 20:11:16 +02:00
Mike Hearn
9ca891c709 Wallet: restrict visibility of the transactions map a bit and tag the others as visible for testing. This should get fixed up in a future refactor. 2014-05-29 20:11:16 +02:00
Mike Hearn
1e4f930b70 Wallet: set lookahead size to 5 when using unit test params instead of scattering calls all over the test code. 2014-05-29 20:11:15 +02:00
Mike Hearn
2be8bc1901 ECKey: make compress/decompressPoint use non-deprecated methods and add a note that BC's tracking of compression state is going to go away. 2014-05-29 20:11:15 +02:00
Mike Hearn
a807994b9a Bump wallet version and add missing check (!) to detect wallets from the future. The absence/incompleteness of this feature had not been noticed before, and it means that old apps will fail to read HD wallets due to the new key enum value rather than a more sensible error (but there's still no chance of an old app accepting an HD wallet, so it should still be safe). 2014-05-29 20:11:15 +02:00
Mike Hearn
c8850c94ae Bugfix: don't throw away deserialized wallet in WalletAppKit 2014-05-29 20:11:15 +02:00
Mike Hearn
ef95eb3b79 Bugfix: don't crash if getEarliestKeyTime is called on a DKC that wasn't initialized with a seed (i.e. a watching chain) 2014-05-29 20:11:15 +02:00
Mike Hearn
704339fdfb Bugfix: copy event listeners to new HD chains when created. 2014-05-29 20:11:15 +02:00
Mike Hearn
2ce5c16815 Switch TestWithWallet to be using an HD key by default. 2014-05-29 20:11:15 +02:00
Mike Hearn
d9fa9e4b68 Fix a casting bug in WalletAppKit. Thanks to Kalpesh Parmar. 2014-05-29 20:11:14 +02:00
Mike Hearn
4df59adeb9 Use setMockClock instead of rollMockClock(0) to resolve flaky tests. 2014-05-29 20:11:14 +02:00
Mike Hearn
51b71a4363 HD Wallets: support watching wallets in Wallet and wallet-tool.
Also, respect includePrivateKeys flag for the seed in wallet.toString again.
2014-05-29 20:11:14 +02:00
Mike Hearn
c7f7fd29e0 HD Wallets: add a REFUND key purpose and map it to the same branch as RECEIVE_FUNDS for now. 2014-05-29 20:11:14 +02:00
Mike Hearn
dbf504faa0 HD Wallets: add getImportedKeys() method that returns just the basic key chain. 2014-05-29 20:11:14 +02:00
Mike Hearn
534252de49 HD Wallets: bugfix, ensure we don't store private keys that can be rederived. 2014-05-29 20:11:14 +02:00
Mike Hearn
3f9791d86a HD Wallets: print seed birthday in wallet dump too 2014-05-29 20:11:14 +02:00
Mike Hearn
a1fcca3883 WalletTool: allow creation of a wallet from a given [word] seed. 2014-05-29 20:11:14 +02:00
Mike Hearn
1ff5d05200 HD wallets: add a Wallet.getKeyChainSeed method. 2014-05-29 20:11:13 +02:00
Mike Hearn
5638387d3a HD wallets alpha preview 2014-05-29 20:11:13 +02:00
Andreas Schildbach
780be05260 Save value of inputs when completing transactions and persist it to the wallet protobuf. Determine the fee of a transaction in case we have all the values. 2014-05-29 20:06:22 +02:00
Andreas Schildbach
03e8934576 Update note about regenerating protobuf bindings. 2014-05-29 20:06:22 +02:00
Mike Hearn
b36bb5bff0 Bloom: don't requery mempool if the filter is only being refreshed to force down FP rate. 2014-05-28 23:09:40 +02:00
Mike Hearn
ecbaaf01d6 Fix scrypt library hash. 2014-05-28 19:19:32 +02:00
Mike Hearn
e95fef3504 Bloom bugfix: track false positives in blocks including when the tx was broadcast within the session, and don't print an error from the wallet in this case. Should have no impact beyond more accurate FP rate calculations. 2014-05-28 18:44:43 +02:00
Andreas Schildbach
344be21821 Fix 'shortest possible pushdata' logic for transaction inputs. Also add a testcase. 2014-05-28 15:43:52 +02:00
Andreas Schildbach
8ca8075a7b Convenience ScriptBuilder.addChunk() method can add arbitrary script chunks. 2014-05-28 15:36:53 +02:00
Andreas Schildbach
9fe8e8ee2b Teach TransactionOutput.toString() to print send-to-pubkey and send-to-multisig types. 2014-05-27 14:50:31 +02:00
Jiri Peinlich
c37423a737 renaming to nonexisting file on Windows
The method fails in case the file does not exists before renaming. canonical.delete() returns false in that case and the method throws an exception.
2014-05-27 13:19:16 +02:00
Andreas Schildbach
ccc3dbd339 Implement standard checks for BIP62 shortest possible data push rules. Also fix ScriptBuilder so it doesn't build longer than necessary data pushes any more. 2014-05-27 11:49:14 +02:00
Andreas Schildbach
7b24a72e45 Implement ScriptChunk.toString() by extracting relevant parts from Script.toString(). 2014-05-27 10:03:56 +02:00
Piotr Włodarek
9c8d2cc600 Renamed proofOfWorkLimit to maxTarget along with get/set and minor refactorings.
* proofOfWorkLimit renamed to maxTarget to get it more inline with commonly used terminology (wiki, etc.)
* some misleading local variables renamed from 'difficulty' to 'target'
2014-05-25 11:44:52 +02:00
Piotr Włodarek
c08c68fc5e Dealt with several compiler notices by verifying and then fixing or suppressing. Reduces compilation output noise. 2014-05-25 11:43:36 +02:00
Piotr Włodarek
cc6090af88 Fixed type references in javadoc to avoid IntelliJ error reports on rebuild. 2014-05-25 11:43:01 +02:00
Piotr Włodarek
b32d0cce17 Improved consistency and formal correctness of all existing .equals methods to meet IntelliJ's convention.
* added null handling so equals methods return false for null argument
* replaced instanceof with getClass to force strict type equality
* added @Override for equals and hashCode where missing
* minor refactorings in equals methods to simplify and improve consistency
* added missing hashCode for ListMessage based on equals definition

Things that HAVE NOT changed:

* set of attributes used for equality checking
* hashCode calculation (except for added hashCode in ListMessage)
* correlation between equals and hashCode
* no new equals methods added
2014-05-22 20:50:42 +02:00
Andreas Schildbach
ff8d76cf7e Include PUSHDATA opcode in Script.toString(). Also, smallNums are printed in their decoded form. 2014-05-22 13:03:32 +02:00
Andreas Schildbach
c236ae418f Keep opcode in ScriptChunk representation of scripts. The goal is to know how data was pushed and be able to apply malleability rules. All unit-tests pass. 2014-05-22 13:03:32 +02:00
Mike Hearn
b47995ed97 Wallet: throw more appropriate exception types during completion.
Resolves issue 560.
2014-05-21 19:38:12 +02:00
Mike Hearn
028a1cca69 Upgrade scrypt library. 2014-05-21 19:25:38 +02:00
Mike Hearn
a07a810ed8 Don't crash if there's no logging handler installed. 2014-05-21 19:25:29 +02:00
Mike Hearn
467124a2b3 Wallet: keep risk dropped txns around in RAM and don't miss them when a Bloom filtered block includes them. Resolves issue 545. 2014-05-21 16:50:17 +02:00
Mike Hearn
ed2948cef1 Correctness fix: compare nBits directly not in BigInteger form as nBits has multiple non-canonical encodings. 2014-05-21 15:09:52 +02:00
Andreas Schildbach
4a5854a599 Reformat log messages in DnsDiscovery and add one log message for the success case, to make more clear what's going on.
Also, rename hostNames to dnsSeeds as this name is more speaking for itself, and is used in other places as well.
2014-05-21 13:22:04 +02:00
Mike Hearn
ee2a91010e PeerGroup: return the peers that match the requested protocol version in waitForPeersOfVersion. 2014-05-20 17:51:45 +02:00
Mike Hearn
dfb3a763ce Add some convenience methods to Transaction for signing. 2014-05-20 17:20:11 +02:00
Mike Hearn
1fe0e7fa6c Add some JavaDocs to FakeTxBuilder 2014-05-20 17:20:11 +02:00
Mike Hearn
2548076fa6 Refactor TestWithPeerGroup a bit to make it more reusable in apps. 2014-05-20 17:20:11 +02:00
Mike Hearn
9e5a06120a Add a PeerGroup.waitForPeersOfVersion API and add unit tests for the waitForPeers* methods. 2014-05-20 14:01:55 +02:00
Mike Hearn
f378bb3a43 Add Addy's main net DNS seed and remove Matt's testnet seed as it doesn't work properly. 2014-05-19 16:17:30 +02:00
Piotr Włodarek
f7e982cee1 Minor refactorings in VersionedChecksummedBytes. 2014-05-18 23:19:55 +02:00
Piotr Włodarek
e91cc443e9 Updated comment for WalletAppKit class to reflect deprecation of start and startAndWait in Guava. 2014-05-18 22:30:22 +02:00
Piotr Włodarek
cd4219ccb1 Fixed comment for Wallet.sendCoins regarding MIN_NONDUST_OUTPUT. 2014-05-18 22:30:09 +02:00
Mike Hearn
443b62481d BloomFilter: set a lower bound on nHashFuncs of 1: there must always be at least one function. Thanks to Kalpesh Parmar for debugging this.
Static import Math for shorter more readable code.
2014-05-13 13:06:48 +02:00
Mike Hearn
cbd91c7ea1 Fixes to tagging, thanks to Andreas for the review.
- Wallet now forces immediate autosave when a tag is set.
- TaggableObject javadocs s/wallet/object/
2014-05-13 13:00:01 +02:00
Mike Hearn
acebe8e3d2 Tighten scope of the FileInputStream in WalletAppKit to avoid lock collisions on Windows. Resolves issue 556. 2014-05-13 12:57:02 +02:00
Mike Hearn
408bca3433 Do tags lazily as was supposed to happen. 2014-05-09 14:56:26 +02:00
Mike Hearn
d68b3b5108 Update script JSON files with latest changes from Peter Todd. 2014-05-09 14:18:13 +02:00
Mike Hearn
268dfe297f Add a simple API that lets you tag wallets with arbitrary string->byte[] pairs. 2014-05-08 20:13:09 +02:00
Mike Hearn
c277dc7e4e Require PeerFilterProviders to expose a lock, and use them to avoid a race that occurs during Bloom filter construction.
It's possible in some uses to cause the Wallet to create two batches of keys one after the other, but independently such that the second batch of keys is derived (with HDWs) whilst the filter is being recalculated from the first. This in turn could race with filter calculation and cause asserts or miscalculated filters.
2014-05-08 00:33:01 +02:00
Mike Hearn
46ad86a9af Refactor bloom filter calculations out of PeerGroup into a separate FilterMerger class. 2014-05-07 21:53:34 +02:00
Mike Hearn
26823d1bf7 Correct the default thread used by AbstractBlockChain.addListener() 2014-05-06 21:44:42 +02:00
Mike Hearn
a893bdd603 PeerGroup: print a log warn if there's no blockchain. 2014-05-05 22:32:46 +02:00
Mike Hearn
0e74eba29f WalletFiles: don't delete temp file if rename failed. It might be the only copy of the wallet we have! Only really should affect Windows. 2014-05-05 14:42:52 +02:00
Mike Hearn
fbbdbb576e Minor reformattings + more javadocs + rename signRequestPki to just signRequest as there are no other signing methods at the moment. 2014-05-05 11:39:07 +02:00
Andreas Schildbach
cdfec498a4 Extract methods for creating and parsing payment requests, payment messages and payment acks, as well as Ack data class. Expose more payment request data from PaymentSession. Add unit tests for roundtripping all messages. 2014-05-05 11:26:25 +02:00
Andreas Schildbach
bd49cd4027 Rename misnamed PaymentRequestException to PaymentProtocolException. It's used for payment messages and maybe payment acks as well. 2014-05-05 11:26:25 +02:00
Mike Hearn
28c16738bc Add a PeerGroup.connectToLocalhost helper method. 2014-05-04 23:43:48 +02:00
Mike Hearn
4df728a7d9 Wallet: add output shuffling (a second time - where did it go?!). It's optional for unit testing. 2014-04-30 23:47:24 +02:00
Mike Hearn
c8ffc1eaee PaymentSession: Expose params and throw if transactions don't match requested params.
Resolves issue 551.
2014-04-30 22:19:39 +02:00
Mike Hearn
6160a2db3d Wallet: expose saveNow/saveLater to subclasses. 2014-04-29 17:33:02 +02:00
Mike Hearn
31c8f8b494 Make wallets autosave every 200msec instead of every second. Also, save immediately upon creation of a fresh wallet in case the app doesn't sync to the network for some reason. 2014-04-28 18:23:31 +02:00
Mike Hearn
119d26fda2 Fix crash 2014-04-27 20:51:44 +02:00
Mike Hearn
3f3f637779 Integrate Tor support into the PeerGroup and WalletAppKit API. 2014-04-27 18:57:56 +02:00
Mike Hearn
6c3b6ce1b3 TorDiscovery: Be less spammy about timed out circuits. A lot always time out. 2014-04-27 18:57:31 +02:00
Mike Hearn
d39cc8838e TorDiscovery: Bugfix. Guava now returns immutable lists from Futures methods (annoying). 2014-04-27 18:11:50 +02:00
Devrandom
9cfb420cdb Use unconnected socket in BlockingClient as before 2014-04-27 17:26:02 +02:00
Devrandom
99448b730a Tor using the Orchid library 2014-04-27 17:26:01 +02:00
Andreas Schildbach
c5e82e6bc5 Expose word list of MnemonicCode. It's useful for auto-completion. 2014-04-25 19:56:03 +02:00
Mike Hearn
8b8adc6fed Add a convenience method to MockTransactionBroadcaster.TxFuturePair 2014-04-25 15:05:16 +02:00
Mike Hearn
38e3f6fb9d Wallet: null out the candidates list after selection so selectors can edit the list if they want. 2014-04-23 15:44:45 +02:00
Mike Hearn
6e999c6054 Simplify the MockTransactionBroadcaster a bit and update the docs. 2014-04-23 00:24:48 +02:00
Mike Hearn
bcc8055b7e Wallet: expose tx broadcaster to subclasses. 2014-04-22 23:06:32 +02:00
Mike Hearn
dd7973c834 Implement equals/hashCode on TransactionInput. 2014-04-22 22:15:10 +02:00
Mike Hearn
c43362e128 FakeTxBuilder: don't throw checked exceptions, it's just annoying. 2014-04-22 16:51:12 +02:00
Mike Hearn
e1d6707626 Move some testing utilities to a new testing subpackage and rename TextUtils to reflect what it actually does. 2014-04-22 16:48:49 +02:00
Mike Hearn
98fc5827f2 Make some accessors on Ping/Pong public. 2014-04-22 16:48:27 +02:00
Andreas Schildbach
b4644fdf81 Fix size of encrypted bytes when encrypting private keys. Also change decrypting to use similar code. 2014-04-22 14:26:08 +02:00
Andreas Schildbach
53147fab16 Add switch to disable download of pending transaction dependencies. This becomes necessary because the current recursive download strategy is often triggering a stack overflow on Android devices. 2014-04-22 14:24:33 +02:00
Andreas Schildbach
b0fa5435a2 Fix parsing of empty labels and messages, and parsing of labels and messages with an unescaped equals sign in their value. 2014-04-22 14:21:11 +02:00
Mike Hearn
b3162cbc17 Fix a crash that can occur if a peer reports a chain height of zero (this is a protocol violation but such crashes were seen in the wild). 2014-04-22 14:03:10 +02:00
Andreas Schildbach
2708df58b3 Adjust MIN_NONDUST_OUTPUT down to 546 only for risk analysis. This is required because we start seeing more and more transactions using the new fee rules introduced with Bitcoin Core 0.9. 2014-04-18 11:57:36 +02:00
Mike Hearn
5c8cf6bc38 Deprecate Script.isSentToP2SH() as it did the same thing as isPayToScriptHash. 2014-04-15 17:28:55 +02:00
Mike Hearn
f19741d2ab Add a toString for reject messages. 2014-04-15 13:34:18 +02:00
Matt Corallo
74d611218b Add (de)serialization support for reject messages. 2014-04-14 17:09:13 +02:00
Mike Hearn
843fa633f3 Re-add verifyPki method to PaymentSession to avoid needless API churn. 2014-04-14 17:05:29 +02:00
Andreas Schildbach
81f62db0e9 Move BIP71 MIME types to PaymentProtocol class. 2014-04-14 16:40:39 +02:00
Andreas Schildbach
40d60306fa Unit tests for signing and verifying both valid and expired payment requests. 2014-04-14 16:40:39 +02:00
Andreas Schildbach
c6b215d79c Add signing of payment requests to PaymentProtocol class. 2014-04-14 16:40:39 +02:00
Andreas Schildbach
4502c40e59 Move verification of payment requests into new PaymentProtocol class. 2014-04-14 16:40:39 +02:00
Andreas Schildbach
f13c437a54 Fix X509UtilsTest ended up in wrong package. 2014-04-14 16:35:39 +02:00
Jakob Stuber
188cf6081d Add support for creating multisig inputs scripts that redeem P2SH outputs 2014-04-14 16:34:24 +02:00
Mike Hearn
2379effd63 ECKey: switch away from the deprecated DERInteger class. 2014-04-08 17:18:01 +02:00
Andreas Schildbach
6087e43377 Upgrade to Guava 16.0.1.
Resolves issue 375.
2014-04-08 16:49:09 +02:00
Mike Hearn
feba332e6e Upgrade to Bouncy Castle 1.50. Patch from Peter Dettman. Resolves issue 497. 2014-04-08 16:28:03 +02:00
Mike Hearn
e372aa4430 Implement equals/hashCode for ECDSA/TransactionSignature, and make them immutable.
Change the canonicalisation method to return a canonicalised copy, if required, and change the name to force users to notice that it's no longer mutating the object.

Resolves issue 544.
2014-04-07 18:41:40 +02:00
Mike Hearn
fbf700391f TransactionInput: verify(): don't crash if the given output has no parent. Clears a static analysis warning. 2014-04-07 18:21:04 +02:00
Mike Hearn
782edd8ea8 TransactionOutput: add equals/hashcode/duplicateDetached methods. 2014-04-07 17:41:04 +02:00
Mike Hearn
af07acd1b6 Payment protocol: add PaymentSession.getNetworkParameters method. 2014-04-07 14:58:55 +02:00
Mike Hearn
8e61a2027f Move X509Utils/TrustStoreLoader, add JavaDocs, and add back a parameter to allow location data to be included in the display name. 2014-04-07 13:27:49 +02:00
Andreas Schildbach
6f4315ed4d Extract loading of X.509 trust stores to TrustStoreLoader. 2014-04-07 12:07:36 +02:00
Andreas Schildbach
e7eec49671 Extract getDisplayNameFromCertificate() into new X509Utils class. Also joins PkiVerificationData.name and .orgName into one .displayName. Adds tests using client/smime certificates of mine. 2014-04-07 12:07:36 +02:00
Andreas Schildbach
e640d1eec3 Cheap test to see if an input stream is a wallet. 2014-04-05 23:14:35 +02:00
Mike Hearn
918ceb8f55 Fix unit test broken by less aggressive backoff time. 2014-04-04 15:23:56 +02:00
Mike Hearn
150e9fb7df More mock clock conversions, to avoid failures when running test cases independently.
Probably we should be injecting a mock Clock class so it goes away at the end of each test, but this would complicate the API somewhat.
2014-04-04 15:06:45 +02:00
Mike Hearn
272ee434c0 Consistently mark parent as nullable in TransactionOutput 2014-04-03 16:26:43 +02:00
Mike Hearn
f9e1b1e9e6 PeerGroup: tweak global backoff to be faster. 2014-04-01 16:53:00 +02:00
Mike Hearn
a2afe470c2 PeerGroup: bugfixes to backoff.
1) Do the wait even on the exception path so if discoverPeers throws, we don't bypass the sleep.
2) Move some field accesses inside the lock.

Resolves issue 527.
2014-04-01 16:48:31 +02:00
Mora Zyx
b720a868a7 Replace usages of currentTimeMillis where result is / 1000 with currentTimeSeconds 2014-03-29 14:41:44 +01:00
Andreas Schildbach
2cbdf324ab Fix race of mock clock with current time if tests are all run sequentially. This commit requires you to use one of the setMockClock() variants before being able to roll it. 2014-03-29 12:01:24 +01:00
Andreas Schildbach
1b0954a84a In Transaction.toString(): For outpoints, show the pubkey-hash of the connected output (if available). This makes it easier to debug wallets. 2014-03-27 11:11:32 +01:00
Mike Hearn
6c5e1344ba Add a Utils.currentTimeSeconds method with a TODO to convert other usages over 2014-03-26 20:05:52 +01:00
Mike Hearn
a31010b379 BloomFilter: javadoc updates 2014-03-26 20:05:52 +01:00
Mike Rosseel
a22cc7f698 mark didn't really make a mark 2014-03-26 16:51:42 +01:00
Andreas Schildbach
b303d77029 Allow shutting down wallet auto-saving. 2014-03-26 13:56:43 +01:00
Mike Hearn
0ed260bae2 Payment protocol: misc enhancements.
Stop using the JDK store and use our own, to make the StartSSL fix effective.
Include the certs in the exception thrown if the chain doesn't verify.
Support loading from a file in the PaymentProtocol tool.
Print the certs out in the PaymentProtocol tool if there's an error.
2014-03-23 19:24:56 +01:00
Mike Hearn
feecc8f486 PaymentSession: extract names from S/MIME certificates as well as SSL certs. 2014-03-23 18:58:08 +01:00
Mike Hearn
822c9011b2 ECKey: fix bug where creation time was lost when encrypting/decrypting. 2014-03-20 14:28:04 +01:00
Mike Hearn
e397928ec3 ECKey: preserve compression state when deserializing from ASN.1.
Resolves issue 528.
2014-03-17 17:42:56 +01:00
Andreas Schildbach
f27558bcd2 Include the hash160 of addresses in Wallet.toString(). This makes it easier to debug wallets just from the dump. 2014-03-17 16:38:51 +01:00
Mike Hearn
a49f643cdc Wallet: disallow adding of keys that don't match the wallet's encryption state. 2014-03-17 16:30:57 +01:00
Andreas Schildbach
22f5e45811 Remove incorrect execution of OP_0. That code was never reached, because OP_0 is not an opcode in terms of chunk.isOpCode()). However, it lead to believe that OP_0 pushes the vector [0], rather than correctly the empty vector to the stack.
Because the code was never executed, this bug could never trigger a test. Afaict, script.cpp does not have the corresponding case in its switch block.
2014-03-17 16:14:44 +01:00
Andreas Schildbach
b17533f8fb Add script test to prove that OP_0 evaluates as the empty vector, rather than [0]. Also adds debug output in case an script_invalid.json test fails. 2014-03-17 16:14:15 +01:00
Mike Hearn
b6149bfa48 Adjust user thread queue size warning. 2014-03-12 14:44:26 +01:00
Pavol Rusnak
8229daf38d BIP-0039: just adapt number of rounds and test vectors 2014-03-10 14:14:16 +01:00
Pavol Rusnak
aa499dfaf8 Revert "BIP-0039 multiple version support."
This reverts commit 1a3c3be665.
2014-03-10 14:14:15 +01:00
Mike Hearn
5226cdc6fc Hex dump pending transactions that double spend each other. 2014-03-10 14:08:38 +01:00
Andreas Schildbach
85d8145924 Add convenience constructor to KeyCrypterScrypt to allow setting the number of scrypt iterations. The default of 16384 is not usable on mobile devices. 2014-03-10 13:39:38 +01:00
Andreas Schildbach
4f8867c58e Fix method name in SendRequest.aesKey javadoc. 2014-03-10 13:35:14 +01:00
Diego Basch
fac6c6fabe added path to files on the Mac 2014-03-07 20:19:18 -08:00
Andreas Schildbach
71ee048d1e Print available balance in Wallet.toString(), rather than the redundant number of Satoshis. 2014-03-07 17:49:58 +01:00
Andreas Schildbach
8fdfb04e43 Update SLF4J to version 1.7.6. Previously, inconsistent versions were used between sub-projects. All unit-tests pass. 2014-03-07 17:47:42 +01:00
Peter Todd
5a8b99b64d
Update BIP URLs to new github repo 2014-03-02 15:01:44 -05:00
Mike Hearn
6025571350 Some minor no-op tweaks to DefaultRiskAnalysis. 2014-02-25 18:09:49 +01:00
Mike Hearn
4eb6bdad88 Add StartCom certificate to the included roots. Resolves issue 515. 2014-02-25 11:43:37 +01:00
Andreas Schildbach
d772244dc9 Fix crash in case wallet is so inconsistent that even .toString() fails. 2014-02-25 11:26:06 +01:00
Mike Hearn
b52faae013 PeerGroup: fix a regression that stopped Bloom filters being sent when a key is added, and add a unit test covering that behaviour.
Resolves issue 524.
2014-02-23 13:12:26 +01:00
Andreas Schildbach
249df81e5d Don't throw just because the name of the CA cannot be determined. 2014-02-21 16:07:35 +01:00
Andreas Schildbach
295e8a154d Fix handling of defaults when parsing the payment message. Bitpay is leaving out the payment details version which was handled incorrectly. Adds a testcase for the defaults. 2014-02-21 18:19:04 +05:30
Mike Hearn
4409891da1 Build a bundled JAR for the core in parallel to the normal unbundled JAR. Helps people who don't use Maven for some reason, like Jython/JRuby users. 2014-02-21 17:30:47 +05:30
Mike Hearn
0a2f7268dc PaymentSession: some bug fixes and new accessors. 2014-02-21 17:30:47 +05:30
Mike Hearn
ce61bd211d Wallet: recursively kill transactions that depend on dead transactions.
Resolves issue 186.
2014-02-21 17:30:45 +05:30
Mike Hearn
51c0f283e2 PaymentSession: javadoc formatting. 2014-02-21 17:27:35 +05:30
Andreas Schildbach
e7ea8483e4 Add method to clean up the wallet.
Currently, it just removes risky pending transaction from the wallet and only if their outputs have not been spent. Includes unit-tests by Miron Cuperman.
2014-02-20 22:19:17 +01:00
Matt Corallo
af1fdd4a14 Add isStandard risk analysis.
This is currently only to deal with recent spam, especially dust sybil spam. Includes an unit-test by Andreas Schildbach.
2014-02-20 22:19:17 +01:00
Andreas Schildbach
5ca6f13195 Replace usage of BigInteger.compareTo(BigInteger.ZERO) with BigInteger.signum() as it's easier to read and more performant. Passes all unit tests. 2014-02-08 15:00:43 +01:00
Mike Hearn
3c86785a89 Payment protocol: Expose a friendly/display name for validating CA 2014-02-07 18:12:18 +01:00
Erik Tierney
59a18ab43f Add ability to optionally use a schema name in the Postgres block store.
Add a test to make sure things work when we set a schema name.
2014-02-07 17:21:26 +01:00
Erik Tierney
c95a864831 Add ctor that takes a connectionUrl instead of hostname and database name.
Avoid exception in close() - only rollback when autocommit is false.
2014-02-07 17:21:26 +01:00
Andreas Schildbach
417c81f54d Use Guavas primitive compare methods, where appropriate. Makes the code easier to read. Passes all unit tests. 2014-02-06 16:28:55 +01:00
Mike Hearn
5f9df48aaa Rename and make the comparators public, documented. 2014-02-06 12:23:37 +01:00
Andreas Schildbach
217da6912d When printing the wallet, apply a sensible order to transaction pools. Again, it helps debugging of wallet problems. 2014-02-06 11:57:59 +01:00
Andreas Schildbach
47c332eb98 Move pending transactions to the top of a wallet printout. It helps debugging, as pending transactions happen to attract most problems. 2014-02-06 11:34:20 +01:00
Mike Hearn
5b74ea5c7b Switch to version 0.12-SNAPSHOT. To the moon! ;) 2014-02-04 11:31:42 +01:00
Mike Hearn
17d52aa404 Fix Maven enforcer hashes. 2014-02-04 11:31:42 +01:00
Mike Hearn
04e7551e99 Move stuff around in the POMs as part of preparing for Maven Central. 2014-02-03 15:42:53 +01:00
Mike Hearn
f4def39f40 H2 is now being exercised more thoroughly and was leaving test db files hanging around that would cause the next run to fail, fix.
Rename method/clean up a bit.
2014-01-31 18:49:58 +01:00
Mike Hearn
f46dc809e4 Add a string c'tor to PaymentRequestException.InvalidPaymentURL 2014-01-31 16:01:00 +01:00
Alex Taylor
c10e029384 Postgres block store, with ability to calculate address balances. 2014-01-31 14:23:40 +01:00
Mike Hearn
00ca0cea0c PeerGroup: pin TransactionBroadcasts from the peer group to avoid premature garbage collection when user code throws away the broadcast future.
Should resolve an issue Ken is having with flaky key sweeping.
2014-01-30 17:46:55 +01:00
Mike Hearn
fff5af29ff Recalculate but don't rebroadcast bloom filters when a p2pubkey output is received.
Resolves issue 513.
2014-01-30 17:43:33 +01:00
Mike Hearn
9204c13233 Move min version for NotFoundMessage to a static member of that class. 2014-01-30 17:18:30 +01:00
Mike Hearn
7c9651a801 Payment protocol: fix broken reflection code for Android. 2014-01-30 15:32:17 +01:00
Mike Hearn
b3bf4aadb7 Payment protocol: re-organise code a bit to handle Android devices that have the javax property set. 2014-01-30 14:40:44 +01:00
Mike Hearn
f94c41e5b6 PeerGroupTest: Clear some minor static analysis warnings. 2014-01-30 14:13:07 +01:00
Mike Hearn
b5127f4414 Make change selectable in regtest mode even if there is only one peer. 2014-01-30 11:23:10 +01:00
Matt Corallo
28b24d0eaa Fix yet another throw-vs-return but in CHECKSIG (resolves #514) 2014-01-30 03:49:37 -05:00
Mike Hearn
a1562836be Payment protocol: Make PaymentSession use a global thread pool that uses daemon threads.
Fixes a 60 second hang that could occur in wallet-tool once the send request was processed. Fixing this revealed another bug - WalletTool was depending on this VM shutdown delay caused by the worker pool timeout, so clean up the code and replace with a blocking get of the future.

Also support the --offline and --password flags when using the payment protocol.
2014-01-28 13:58:08 +01:00
Mike Hearn
ddec4f9106 Allow Bitcoin URI's that don't have any address component if the r= payment protocol param is there. 2014-01-28 13:04:09 +01:00
Kevin Greene
3966875e8e Adding support for processing PaymentRequests. 2014-01-28 09:46:51 +01:00
Simon de la Rouviere
4ca476ff35 When throwing InsufficientMoneyException, the amount of satoshis missing is required. When the server requests too much value, it is stored so that implementations of the client has access to it. 2014-01-25 18:14:06 +01:00
Matt Corallo
bd5c4e73e7 Prevent memory blowup on orphan storage 2014-01-23 10:37:47 +00:00
Ken Sedgwick
1a3c3be665 BIP-0039 multiple version support. 2014-01-19 09:46:47 +01:00
Mike Hearn
654543bb2b BlockingClient: some fixes for Orchid 2014-01-15 23:16:04 +01:00
Mike Hearn
ae1e3691f5 WalletAppKit: Allow subclasses to fiddle with some more stuff.
This isn't really a stable or supportable API, but bitcoinj does not have a stable API, so live and let live.
2014-01-15 21:26:53 +01:00
Mike Hearn
80d4840199 Threading: prefer OOM to deadlock when the user thread is saturated, but keep the warning. 2014-01-15 17:56:10 +01:00
Mike Hearn
a9a7dd9e06 Lower the priority of the networking thread to avoid competing with UI threads. 2014-01-15 15:11:31 +01:00
Mike Hearn
8e58839d81 Wallet: Short-circuit runnable creation if executor is SAME_THREAD 2014-01-15 01:56:07 +01:00
Mike Hearn
b8a1976422 Fix an edge case bug I just introduced a few minutes ago with the txConfidenceListener changes, and document. 2014-01-14 19:24:49 +01:00
Mike Hearn
3a405302bb More memory optimisations.
Run the wallet txConfidenceListener on the calling thread. Move tx broadcast that occurs inside setTransactionBroadcaster outside the wallet lock to avoid inverting on the mempool class (via PeerGroup, but that doesn't lock on the broadcast path).

This makes memory usage smoother by avoiding the creation of tons of closures and spamming the event thread with them.
2014-01-14 19:06:06 +01:00
Mike Hearn
d7b3766c4b Memory optimisations to avoid OOM when the user thread falls behind.
- Remove needless recalculations of the Bloom filter on any wallet change, instead of just when keys/scripts are added. This may fix one of the privacy leak issues too.
- Run fast catchup/filter recalculations on the dedicated PeerGroup thread instead of abusing the user thread. Resolves a TODO.
- Replace the user thread SingleThreadedExecutor with a custom class that blocks the submitting thread and logs a warning if the queue is saturated, to avoid building up a backlog of closures.
2014-01-14 18:49:09 +01:00
Mike Hearn
e0b698a2e9 Threading: experiment with limiting the user/event thread to 100 pending closures. 2014-01-14 15:25:38 +01:00
Mike Hearn
941bf330a4 Script: intern commonly used chunks. 2014-01-13 14:58:31 +01:00
Mike Hearn
843489111e Quick hack to try and reduce memory consumption for Androids.
Takes a test wallet from around 11.3mb to 9.6mb
2014-01-13 14:58:31 +01:00
Mike Hearn
d50412e24c Wallet: log exceptions during save. 2014-01-13 14:25:01 +01:00
gubatron
0c2f362795 refactor s/Utils.now().getTime()/Utils.currentTimeMillis()/g 2014-01-07 16:16:02 +01:00
Mike Hearn
7324798242 Remove some superfluous methods in HDUtils 2014-01-07 15:23:26 +01:00
Mike Hearn
34e2d1596f Address: rename a static ctor method to be more accurate. 2014-01-07 15:22:00 +01:00
Mike Hearn
351299c9ab Add a new DNS seed from Chris Decker.
Vouch: Chris is a researcher at ETH Zurich who I have met several times. He has run several useful experiments and analyses on the Bitcoin network.
2014-01-06 15:23:35 +01:00
Mike Hearn
d0cd770d62 Cleanup.
Add lots more nullity annotations.
Clear lots of nullity static analysis warnings.
Delete some dead code.
Simplify a few expressions.

Resolves issue 317.
2013-12-24 00:40:19 +00:00
Devrandom
3d99be48bc Priority queue and exponential backoff for PeerGroup
Connect to peers in a service loop thread.

Resolves issue #159
Resolves issue #503
2013-12-23 22:57:19 +00:00
Mike Hearn
b0ce535aa9 PeerGroup: clear some static analysis warnings. Remove dead code. 2013-12-23 21:45:01 +00:00
Mike Hearn
aaa539bd80 Networking: bump default connect timeout to 5 seconds.
Improve some logging.
2013-12-23 20:00:24 +00:00
Mike Hearn
1f37350161 Transaction: clear a couple of static analysis warnings. 2013-12-22 19:13:41 +01:00
Mike Hearn
c5665d68b5 Wallet: misc cleanups.
Clear some static analysis warnings.
Throw more appropriate exception types in some cases.
Add a few internal assertions.
Better nullity annotations.
2013-12-22 19:13:23 +01:00
Mike Hearn
f318808cf7 Clean up WalletTransaction and serialization code a bit. 2013-12-22 19:04:24 +01:00
Mike Hearn
b3673999d4 Move WalletTransaction into the wallet package. 2013-12-22 18:48:46 +01:00
Mike Hearn
43460f451a MnemonicCode: Clean up a bit. 2013-12-20 17:35:11 +01:00
Ken Sedgwick
29e2af7ec0 Update to latest version of mnemonic code spec from the Trezor team. 2013-12-20 17:15:24 +01:00
Mike Hearn
8cc1920fa2 ECKey: use sumOfTwoMultiples for better/faster key recovery.
Thanks to Peter Dettman for the tip. Resolves issue 492.
2013-12-15 14:55:43 -08:00
Mike Hearn
e9bf717409 ConnectionHandler: Remove a always-true if condition. 2013-12-15 09:31:07 -08:00
Mike Hearn
25a08c6d75 NioClientManager: minor fix revealed by static analysis. 2013-12-15 09:29:59 -08:00
Mike Hearn
42e75b86cf PeerGroup: add a couple of missing nullable annotations 2013-12-15 09:27:38 -08:00
Matt Corallo
c61ec5023e Fix race in TestWithNetworkConnections
There was a nasty bug where a connection-failed interrupt was
run afer any interruptible calls were made, making the next
test-case fail due to interruption.
2013-12-15 09:27:19 -08:00
Mike Hearn
f7a944983c ECKey: use Bouncy Castle to decompress keys. Thanks to Peter Dettman for the hint. Resolves issue 493. 2013-12-14 14:12:52 -08:00
Mike Hearn
8f48b119b7 AbstractBlockChain: minor style fixes from the inspector. 2013-12-14 13:35:22 -08:00
Mike Hearn
30455cb5ce Suppress some more info logging and update some javadocs. 2013-12-14 13:21:33 -08:00
Devrandom
462c75324e Faster FP tracking using double exponential 2013-12-14 12:42:44 -08:00
Mike Hearn
1293e42aa3 BloomFilter: minor readability tweak 2013-12-14 11:42:41 -08:00
Matt Corallo
2f29660d0d Fix broken test case. 2013-12-14 01:11:52 -05:00
Mike Hearn
77f99a596f Log balance in wallet.toString better 2013-12-13 16:57:28 -08:00
Mike Hearn
cdfa0ae61b ECKeyTest: once again, fix a flaky decrypt test. There's no MAC on the encrypted bytes so you can't assume padding checks will always catch corrupted data. 2013-12-13 16:08:54 -08:00
Devrandom
7e4f6369e4 Clean up false positive handling, add unit test 2013-12-13 16:00:42 -08:00
Devrandom
ba9415b3ee Force update Bloom filter when false positive rate gets high 2013-12-13 16:00:41 -08:00
Devrandom
751434ba7c Fix bloom filter sizing with watched scripts 2013-12-13 15:59:07 -08:00
Mike Hearn
86b42b7fe5 Remove disconnectOldVersions2 as it tests nothing, probably a bad merge conflict. 2013-12-13 15:55:08 -08:00
Mike Hearn
e4e2e60627 Fix DnsDiscovery javadocs and make a couple of fields final. 2013-12-13 09:29:08 -08:00
Mike Hearn
c278867186 Add a unit test for Script.toString and don't emit trailing whitespace. 2013-12-12 08:11:23 -08:00
Mike Hearn
4bbcfc4377 Don't print script creation timestamp in Script.toString() 2013-12-12 08:09:15 -08:00
Mike Hearn
22a58755db Print peer times using String.format. Resolves issue 495. 2013-12-11 19:13:46 -08:00
Mike Hearn
2f8740f8a8 Remove usage of deprecated method in PeerTest. 2013-12-11 10:39:31 -08:00
Mike Hearn
24d38cdba4 Check for and reject null event listeners. 2013-12-11 10:00:35 -08:00
Matt Corallo
2879f7bb9b Fix memory leak of downloadListener 2013-12-11 10:00:35 -08:00
Ken Sedgwick
a0f32ab0d2 Improved comment. 2013-12-10 17:49:45 -08:00
Ken Sedgwick
e86ce7f268 Updated to latest version of BIP-0039. 2013-12-10 17:49:45 -08:00
Ken Sedgwick
5cd10a537a Added Mnemonic{Length,Word,Checksum}Exception and tests for each case. 2013-12-10 17:49:45 -08:00
Mike Hearn
69f52c1b8a Bug fix to avoid a flake in PeerTest.
There seem to be other cases where unit tests can be flaky with nonetty. More fixes will come later.
2013-12-10 13:51:18 -08:00
Mike Hearn
ce4ac86884 Move discovery package into net package. 2013-12-10 13:13:52 -08:00
Mike Hearn
3318d15194 Rename networkabstraction package to just net 2013-12-10 13:12:22 -08:00
Matt Corallo
c10ebd260c Fix reentrance bug when writing in connectionOpened. 2013-12-10 13:03:15 -08:00
Matt Corallo
ba543a3b10 Only do network writes on the handler thread in nio wrappers 2013-12-10 13:03:15 -08:00
Matt Corallo
abe9513dde Don't allow setting writeTarget twice. 2013-12-10 13:03:15 -08:00
Mike Hearn
4b035535e2 nonetty: Print fewer stack traces on errors. Handle failure of initial connect call. 2013-12-10 13:03:15 -08:00
Mike Hearn
68a614a33b nonetty: Fix a couple of unit test bugs.
Remove references to netty that still appeared in comments/POM
2013-12-10 13:03:15 -08:00
Matt Corallo
534cec9791 Rewrite the network stack.
Remove Netty entirely, using the new Nio wrapper classes instead

* BitcoinSerializer now uses ByteBuffers directly instead of
  InputStreams.
* TCPNetworkConnection and NetworkConnection interface deleted,
  Peer now extends the abstract class PeerSocketHandler which
  handles deserialization and interfaces with the Nio wrapper
  classes.
* As a part of this, all version message handling has been moved
  to Peer, instead of doing it in TCPNetworkConnection.
* Peer.setMinProtocolVersion() now returns a boolean instead of a
  null/non-null future which holds the now-closing channel.
* Peer.sendMessage (now PeerSocketHandler.sendMessage()) now
  returns void.
* PeerGroup has some significant API changes:
  * removed constructors which take pipeline factories,
    makePipelineFactory, createClientBootstrap
  * Replaced with a setSocketTimeoutMillis method that sets a
    timeout between openConnection() and version/verack exchange.
    (Note that because Peer extends AbstractTimeoutHandler, it has
    useful timeout setters public already).
  * connectTo returns a Peer future, not a ChannelFuture
  * removed peerFromChannelFuture and peerFromChannel
* Peer and PeerGroup Tests have semi-significant rewrites:
  * They use actual TCP connections to localhost
  * The "remote" side is a InboundMessageQueuer, which queues
    inbound messages and allows for writing arbitrary messages.
  * It ignores certain special pings which come from pingAndWait,
    which is used to wait for message processing in the Peer.
  * Removed a broken test in PeerGroupTest that should be reenabled
    if we ever prefer a different version than our minimum version
    again.
  * Removed two duplicate tests in PeerTest (testRun_*Exception)
    which are tested for in badMessage as well.
  * Added a test for peer timeout and large message deserialization

Author:    Matt Corallo <git@bluematt.me>
2013-12-10 13:03:14 -08:00
Mike Hearn
81f8b230e3 Script.toAddress now can cast to P2SH addresses. 2013-12-10 11:45:29 -08:00
Mike Hearn
ea6f2a0fc3 Payment channels: invoke destroyConn on server side even when client requested it.
This allows servers to do something useful when the channel closes normally, like forward the money onwards.
2013-12-10 11:39:30 -08:00
Mike Hearn
54b1054d03 Add a couple of utility methods for working with P2SH scripts. 2013-12-10 11:38:45 -08:00
Mike Hearn
cebebcef69 Fix unit test failure caused by bad merge. Resolves issue 489. 2013-12-01 13:04:25 +01:00
Mike Hearn
963978c468 Add watched scripts to the wallet toString output.
Support watching scripts/addresses in WalletTool
2013-11-30 16:39:58 +01:00
Devrandom
da2e3e6c98 Support watching of scripts/addresses in wallet 2013-11-30 16:39:58 +01:00
Mike Hearn
2271e7198e Better error handling in Address. 2013-11-30 15:33:24 +01:00
Mike Hearn
98081f0568 Support sending to P2SH addresses. Thanks to Mike Belshe.
Resolves issue 461.
2013-11-30 15:14:52 +01:00
Mike Rosseel
7083c8b669 Increase test coverage. 2013-11-27 17:55:43 +01:00
Mike Hearn
70cd2ffb96 Wallet: throw exceptions when completing a transaction fails.
If there's insufficient balance (typical error) then InsufficientMoneyException is thrown (checked).
If the SendRequest is bad in some way, like asking to create a spend that would violate the protocol rules, IllegalArgumentException is thrown (unchecked).

Also make VerificationException (and thus ProtocolException+ScriptException) unchecked.

Resolves issue 425.
2013-11-27 15:25:52 +01:00