Commit Graph

1181 Commits

Author SHA1 Message Date
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
Ken Sedgwick
02ce88e6a3 Added buffer to MnemonicCode, it was modifying it's key argument (stretching in place). 2013-11-25 11:24:46 +01:00
Mike Hearn
ff678d116f ECKey: some more nullity checks/annotations. 2013-11-25 00:08:06 +01:00
Mike Hearn
a5d14ba45b HDW: Add some docs and a safety check to HDKeyDerivation. 2013-11-25 00:04:11 +01:00
Mike Hearn
8769773717 Add a default c'tor to MnemonicCode and simplify the unit tests. 2013-11-25 00:04:11 +01:00
Mike Hearn
3569dfe2d4 Payment channels: fix a simple thread-affinity bug revealed by a flaky unit test. It does not affect real apps.
Disable signature checking in ChannelTest to make it run faster, especially in the debugger, and bump timeouts so client/server don't timeout when debugging.
2013-11-21 13:29:01 +01:00
Mike Hearn
a9469758fd ECKey: allow unit tests to disable signature creation/verification. 2013-11-21 13:29:01 +01:00
Mike Hearn
857b34fcee Wallet: don't call killTx if it has no work to do, cleans up a misleading log line. 2013-11-21 13:29:01 +01:00
Mike Hearn
434f7d003a Wallet: always broadcast all pending txns, not only those that are unmarked. 2013-11-20 23:19:12 +01:00
Mike Hearn
3161c6c7ba TransactionBroadcast: add a unit test that verifies the rebroadcast functionality works. 2013-11-20 14:53:34 +01:00
Mike Hearn
62078f55c0 TransactionBroadcast: when there are an odd number of peers, bias towards more receivers rather than more announcers. 2013-11-20 14:53:17 +01:00
Mike Hearn
44944a62d0 Payment channels: clear a static analysis thread safety warning. 2013-11-18 18:54:43 +01:00
Ken Sedgwick
8dcead3508 Added MnemonicCode, implements BIP-0039. 2013-11-18 11:28:55 +01:00
Mike Hearn
c11456c9f4 Wallet: improve double spend handling.
Now connects all inputs of an overriding transaction, meaning balance is correct if a bit-tweaked but semantically identical transaction double spends its shadow (e.g. during key rotation on a cloned device).

Still does not recursively kill transactions however.

Resolves issue 439.
2013-11-18 00:17:07 +01:00
Mike Hearn
e49255c9e0 Experimental tweak to the definition of the numBroadcastPeers confidence field: now it actually does what the name implies. 2013-11-17 23:13:07 +01:00
Mike Hearn
e636ee2927 Take out a flaky part of WalletTest that isn't relevant anymore since even immediate auto-saves now run on a separate thread. The auto-saving is tested elsewhere anyway. 2013-11-17 23:08:08 +01:00
Mike Hearn
9c35501662 Payment channels: bump protocol version.
The protocol gained a PAYMENT_ACK message and now requires a min payment up front. Thus, it is incompatible with previous versions.
2013-11-13 18:30:14 +01:00
Mike Hearn
fc70f7362d Payment channels: require a minimum payment to initiate.
This is a (backwards incompatible) protocol change that prevents clients or servers getting into a situation where they have opened a channel that they then cannot close because insufficient value has been transferred.

The server is allowed to specify the minimum payment it requires in order to open any channel at all, and the client then sanity checks that. Currently the rule is very simple - the min payment must be equal to the hard-coded dust limit. In future it will get more complicated as the dust limit starts to float and a more nuanced risk analysis may become required.
2013-11-13 18:18:10 +01:00
Mike Hearn
bba5e2b449 Payment channels: expose server state object via PaymentChannelServer property 2013-11-13 18:18:01 +01:00
Mike Hearn
6c40363c3d Payment channels: expose whether a channel was initiated or resumed in the ClientConnection interface. 2013-11-13 18:18:01 +01:00
Mike Hearn
d41814ced2 FullPrunedBlockChainTest: add more debug logging. 2013-11-13 18:18:01 +01:00
Mike Hearn
9045add4c0 Add missing copyright headers in a few places. 2013-11-12 13:39:25 +01:00
Mike Hearn
0bc28781ae Payment channels: rename "close" to "settle".
The previous overloading of the term "close" to mean both settlement of the channel (broadcast of the final payment tx) and terminating/cleaning up the underlying network connection was very confusing and made the code harder to work with. The notion of "closing" a protocol that is often embedded inside others isn't really well defined, so there's perhaps more work to do here, but this change makes the code easier to follow and is basically a big pile of no-ops.
2013-11-12 13:37:46 +01:00
Mike Hearn
edf37998ca Wallet: improved risk analysis.
Extract out the "is time locked" risk analysis code to a pluggable implementation.
Ensure the default implementation has 100% test coverage.
Consider finality, not merely the presence of a lock time, when judging risk.
Don't consider a tx risky if it would become final in the next  block.
Do not consider self-created transactions risky.
2013-11-11 19:07:44 +01:00
Mike Hearn
c33c20fe3d Wallet: record the timestamp of the last block seen. 2013-11-11 17:54:21 +01:00
Mike Hearn
32009c5250 Cleanup: use varargs methods in slf4j rather than new Object[]{} 2013-11-11 17:21:34 +01:00
Matt Corallo
0506b1b30c Fix yet another dumb script bug (resolves issue 479) 2013-11-11 03:31:47 -05:00
Mike Hearn
bf47b872c0 Tweak broadcast logic again.
Now broadcast to half the connected peers immediately, and wait until half of the rest (i.e. a quarter) have announced the tx. This should give some robustness against a random subset of peers silently swallowing transactions.
2013-11-10 20:06:47 +01:00
Mike Hearn
4da8fbc301 Add a builder function to InventoryMessage 2013-11-10 20:05:22 +01:00
Mike Hearn
688ba42c45 WalletTool: allow skipping of mandatory extensions.
This allows it to read MultiBit wallets.
2013-11-10 20:03:30 +01:00
Mike Hearn
a68bc627ee TransactionBroadcast: refactor 2013-11-10 18:08:50 +01:00
Matt Corallo
b9363999ae Fix signedness issue reading scripts (resolves issue 478) 2013-11-08 12:32:47 -05:00
Mike Hearn
f6fb6c211d Payment channels: extract an IPaymentChannelClient interface for the basic PaymentChannelClient operations.
This is useful for code that wants to make micropayments in a generic fashion, whilst being independent of whether the implementation is in-process using a local wallet, or perhaps running elsewhere (like inside an Android wallet app with communication happening using Binder RPC).
2013-11-04 16:37:17 +01:00
Matt Corallo
5304a55d86 Fix b61 creation (why was it written this way in the first place?) 2013-11-01 15:38:05 +01:00
Matt Corallo
f2678463be Fix race condition in NioWrapperTest testcase (resolves issue 474) 2013-11-01 15:37:40 +01:00
Matt Corallo
2d36b89bb9 Update script json tests from upstream 2013-11-01 15:32:41 +01:00
Matt Corallo
8fc7a2a34b Fix RegTestParams subsidy decrease block count (150) 2013-11-01 15:32:29 +01:00
Mike Hearn
aff5f140fb Payment channels: add payment acks.
Add a new PAYMENT_ACK message to the protocol. Make incrementPayment return a future that completes when the server has acknowledge the balance increase.

Also, prevent users from overlapping multiple increase payment requests.

This resolves race conditions that can occur when the billed-for activity is asynchronous to the protocol in which the micropayment protocol is embedded. In this case, it was previously impossible to know when the async activity could be resumed as it would otherwise race with the process of the server checking the payment signature and updating the balance. Most applications of micropayments will use a single protocol that has been extended with an embedding, and thus this is not an issue. However in some rare applications the payment process may run alongside the existing protocol rather than inside it. In this case, payment acks should be used for synchronization.
2013-11-01 15:31:57 +01:00
Mike Hearn
06ac0105f3 Payment channels: make ProtobufParser use finer grained, cycle detecting locking. 2013-11-01 13:00:26 +01:00
Mike Hearn
c36989cfce MockTransactionBroadcast: add to wallet. 2013-10-30 13:35:24 +01:00
Matt Corallo
2468100937 Fix some Script nits/add comments. Thanks Peter Todd 2013-10-28 10:52:29 +01:00
Mike Hearn
bd6a5f62d9 PeerGroup: Split some broadcast related code out into a separate class.
This is in anticipation of it getting larger and more complicated.
2013-10-27 18:28:15 +01:00
Mike Hearn
16fb2f83eb Wallet: fix a couple of bugs.
1) TX confidence listeners were being run for chain height changes, even if they were not confirmed yet.

2) req.fee was being miscalculated for empty wallet transactions.
2013-10-27 18:24:37 +01:00
Mike Hearn
a3356c511a TestWithWallet: add a TODO to clean it up 2013-10-27 18:23:06 +01:00
Mike Hearn
4d23183283 Disable fragmentedRekeying test for now as bouncy castle is so slow at signature generation 2013-10-27 18:09:27 +01:00
Mike Hearn
9d96f77f19 PeerGroup: add logging of the change reason to the broadcast confidence listener. Also attach the listener to the pinned TX (it shouldn't make any difference normally, but when mixed with bluetooth stuff it might possibly change things). 2013-10-27 15:37:06 +01:00
Mike Hearn
387717c6c5 Wallet template: various updates.
Backport misc improvements from PayFile.
Refactor the clickable address out into a custom widget.
Use FontAwesome and the wrapper class for icons instead of a custom image.
QRcode support.
2013-10-26 02:28:44 +02:00
Mike Hearn
6ec7880079 Payment channels: add a method to obtain the seconds remaining until next channel expiry for a given server ID.
This is useful for UIs that need to tell the user what's going on when there's a connect-back failure.
2013-10-24 11:12:18 +02:00
Mike Hearn
5a3aa5d6e1 Remove redundant query in H2FullPrunedBlockStore.
Patch from Eric W Dickerson. Resolves issue 441.
2013-10-23 14:22:44 +02:00
Mike Hearn
f315125bf5 ECKey: Always use the canonical form of the S component.
This is a part of the general Bitcoin protocol anti-tx malleability work.
2013-10-23 13:08:21 +02:00
Mike Hearn
32a823804c Payment channels: server closes/settles the channel automatically if the client has sent the last remaining money in it.
Also, throw an exception if the client tries to submit a  rolled back amount of money instead of silently ignoring it.
2013-10-16 19:26:02 +02:00
Mike Hearn
5b28091c9a Payment channels: split CLOSE message processing on the server side into a separate method. 2013-10-16 19:26:02 +02:00
Mike Hearn
31a4c08615 VarInt: remove superfluous and bizarrely named encodeBE method. 2013-10-15 18:34:17 +02:00
Mike Hearn
2f0dfd5c1b FullBlockTestGenerator: treat coinbase scriptSig as a 16-bit counter not 8 bit.
This bug led to mysterious failures that only showed up when tests were run in a certain order and the counter happened to wrap around exactly.
2013-10-14 18:16:57 +02:00
Mike Hearn
5a673ebe7e Untabify 2013-10-14 12:33:04 +02:00
Mike Hearn
854d81eae9 Don't run confidence listeners if we get duplicate invs from the same peer (can happen if we connect to the same peer IP multiple times). 2013-10-14 12:05:18 +02:00
Mike Hearn
dfa722ccc8 Wallet: track relative ordering of transactions within a block.
Ensures re-orgs don't replay transactions out of order. Resolves issue 468.
2013-10-14 10:56:21 +02:00
Mike Hearn
9669758c66 Update slf4j hashes in the dependency verifier. 2013-10-11 15:01:12 +02:00
Mike Hearn
f27430c356 Refactor/bugfix broadcast of pending transactions when a peergroup starts up.
Previously the PeerGroup itself would broadcast the pending transactions by simply sending an inv with them all to every peer. This is a good way to get a transaction blasted out if there are no problems with it, but it means we cannot track propagation and the numBroadcastPeers() value was correspondingly not increased. This seems to be causing issues with the Android wallet. So try out a different approach - have the wallet use broadcastTransaction as per normal on the PeerGroup when it's added. The TX will be propagated and watched as with a normal spend.
2013-10-11 14:50:53 +02:00
Mike Hearn
a051afe224 Payment channels: default server should not attempt to destroy the [TCP] connection after sending a CLOSE, let the client do that.
This resolves some complicated state management issues in some kinds of client (like on Android).  It's also just generally a part of the work to divorce the notion of settling a channel from closing underlying protocol connections.
2013-10-10 14:23:57 +02:00
Mike Hearn
4b48dbfda9 Payment channels: plumb through the actual amount of value sent on a channel, as it can sometimes be different to how much was requested. 2013-10-09 18:15:04 +02:00
Mike Hearn
6625c9a2cb Use earliest key time minus a week for setting fast catchup time and selecting a checkpoint.
This handles clock drift both in the block headers and possibly wrong times in the users clock (broken timezone, etc).

Resolves issue 460.
2013-10-08 11:49:53 +02:00
Mike Hearn
6c8a8aa691 Threading: resolve a race in the unit tests: if the user thread wasn't initialised, don't crash trying to test if we're on it. 2013-10-08 11:47:06 +02:00
Mike Hearn
8beb26c421 ScriptTest: more helpful errors. 2013-10-07 18:09:47 +02:00
Mike Hearn
1f7dd9495e Script: clone tx before performing correctlySpends check. This prevents thread safety issues and corrupted transactions if validation fails. 2013-10-07 18:09:38 +02:00