Commit Graph

92 Commits

Author SHA1 Message Date
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
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
022e7c27fe Wrap coin-ish BigIntegers into Coin class. 2014-05-30 15:09:32 +02:00
Mike Hearn
5638387d3a HD wallets alpha preview 2014-05-29 20:11:13 +02:00
Mike Hearn
8ff52f5217 Payment channels: update example client to reflect API changes. 2014-05-28 13:26:19 +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
Mike Hearn
0942bb57b5 Add a double spending test program 2014-04-15 13:35:11 +02:00
Andreas Schildbach
6087e43377 Upgrade to Guava 16.0.1.
Resolves issue 375.
2014-04-08 16:49:09 +02:00
Mike Hearn
829656b153 Correct maven instruction in the README file and make ForwardingService work on mainnet again by fixing command line arg parsing.
Resolves issue 523.
2014-03-10 17:36:32 +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
Mike Hearn
5b74ea5c7b Switch to version 0.12-SNAPSHOT. To the moon! ;) 2014-02-04 11:31:42 +01: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
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
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
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
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
533e2f21b7 Delete ToyWallet example. It's redundant with the wallettemplate app now. 2013-10-27 17:15:42 +01:00
Mike Hearn
95f528a340 Add more features to WalletAppKit, and ensure wallets it creates always have at least one key. 2013-09-15 20:24:52 +02:00
Mike Hearn
9bd52196ed Payment channels: Shrink the payment channel server example min required value to make it more micropaymenty. 2013-09-04 13:27:10 +02:00
Mike Hearn
b20f0c306c Remove verifier from examples/pom.xml, it requires us to wait for reproducible build support to land. 2013-08-11 16:47:26 +02:00
Mike Hearn
08afe9044d Move verifier XML around. 2013-08-11 16:45:07 +02:00
Mike Hearn
2808b062d7 Version 0.11-SNAPSHOT 2013-07-30 14:47:39 +02:00
Mike Hearn
435d4e85b0 Update copyright year on ForwardingService. 2013-07-29 18:35:26 +02:00
Mike Hearn
9adb275e6d Rename and rewrite PingService. It
It's now just ForwardingService, doesn't use the "from address" concept anymore, and uses WalletAppKit + balance futures. The new code is much simpler and easier to read.
2013-07-29 17:19:28 +02:00
Mike Hearn
ce1d8315ea Payment channels: tweaks to the examples.
Print wallet state at various points. Demonstrate disconnecting vs closing channels.
2013-07-25 15:32:17 +02:00
Mike Hearn
dcf04f6cb6 Payment channels: inline a superfluous misnamed method on StoredServerChannel and rename getState to getOrCreateState. 2013-07-19 15:55:30 +02:00
Mike Hearn
4f9bc98e97 Payment channels: Re-order c'tor of StoredPaymentChannelClientStates.
This makes it consistent with the server side and put the listener last. It's easier to read this way when an anonymous inner class is used.
2013-07-19 15:55:30 +02:00
Mike Hearn
99f32b16af Introduce UnreadableWalletException and make WalletProtobufSerializer throw it in all cases where there's a problem reading the wallet. Resolves issue 415. Resolves issue 416. 2013-07-11 16:04:00 +02:00
Mike Hearn
f473267da2 Exception handling: provide a global variable in Threading that receives all unhandled exceptions from all framework threads.
Replaces the now removed PeerEventListener.onException() callback.
2013-07-09 14:47:38 +02:00
Mike Hearn
6b7d653614 Major rework of how confidence listeners are called:
* API change: TransactionConfidence.Listener now takes a reason enum describing the general class of change.
* Confidence listeners are now invoked in the user code thread as well, thus eliminating any chance of unexpected re-entrancy.
* The wallet batches up confidence changes and executes them all at the end of major operations, avoiding confusing intermediate transitions that could occur in the previous design.
* Much code has been simplified as a result and it's now harder to screw up.
2013-07-05 10:54:19 +02:00
Matt Corallo
4908c241f7 Implement server-side and client-side payment channel protocols.
This implements micropayment payment channels in several parts:
 * Adds PaymentChannel[Server|Client]State state machines which
   handle initialization of the payment channel, keep track of
   basic in-memory state, and check data received from the other
   side, based on Mike Hearn's initial implementation.
 * StoredPaymentChannel[Client|Server]States manage channel
   timeout+broadcasting of relevant transactions at that time,
   keeping track of state objects which allow for channel
   resume, and are saved/loaded as a WalletExtension.
 * Adds PaymentChannel[Client|Server] which manage a connection
   by getting new protobufs, generating protobufs for the other
   side, properly stepping the associated State object and
   ensuring the StoredStates object is properly used to save
   state in the wallet.
 * Adds PaymentChannel[ClientConnection|ServerListener] which
   create TCP sockets to each other and use
   PaymentChannel[Client|Server] objects to create/use payment
   channels.

The algorithm implemented is the one described at
https://en.bitcoin.it/wiki/Contracts#Example_7:_Rapidly-adjusted_.28micro.29payments_to_a_pre-determined_party
with a slight tweak to use looser SIGHASH flags so that the
Wallet.completeTx code can work its magic by adding more inputs if
it saves on fees.

Thanks to Mike Hearn for the initial state machine implementations
and all his contracts work and Jeremy Spilman for suggesting the
protocol modification that works with non-standard nLockTime
Transactions.
2013-06-27 14:15:49 +02:00
Mike Hearn
8b8bf50144 Version 0.10-SNAPSHOT 2013-06-18 16:33:06 +02:00
Mike Hearn
332967f0bd PingService: allow usage of regtest mode, always include a fee in the bounce transaction, don't use from addresses anymore. 2013-06-17 14:57:02 +02:00
Mike Hearn
f4c3b6a49d Global search and replace to use the param-class specific instance getters and prodNet -> MainNetParams.
The old "prodnet" name could be confusing to non-native speakers or people who just haven't been exposed to Google lingo. Main net is more idiomatic.

Conflicts:
	tools/src/main/java/com/google/bitcoin/tools/BlockImporter.java
2013-06-05 14:10:40 +02:00
Mike Hearn
8043bc335b NetworkParameters: hide port behind a getter. 2013-06-05 14:10:38 +02:00
Mike Hearn
f88bdc5fe3 Wallet: make keychain private and add a remove method. 2013-04-22 13:45:38 +02:00
Mike Hearn
f1845dd552 Version 0.9-SNAPSHOT 2013-04-11 14:27:35 +02:00
Mike Hearn
9449897e2d Fix PingService re-entrancy. 2013-04-09 15:16:04 +02:00
Mike Hearn
3d6691c82a Switch to using DNS for testnet discovery, as LFnet has gone away.
Put DNS seeds into NetworkParams.
Deprecate IrcDiscovery and remove the unit tests for it.
Update examples and tools to use DNS for everything.
Resolves issue 299.
2013-03-29 17:39:24 +00:00
Mike Hearn
57b3fb4368 Bump language level to java 6 in the pom and fix the ToyWallet demo. 2013-03-19 15:40:52 +01:00
Mike Hearn
5d0518dafd Merge encrypted wallets functionality by Jim Burton. 2013-03-18 18:27:12 +01:00
Mike Hearn
c8c1e68152 Unlock TransactionConfidence event listeners, make sure MemoryPool is not locked when a tx is marked broadcast by a peer to avoid inversions via listeners.
Unfortunately this introduces some new FindBugs warnings because it doesn't understand the inside-out locking pattern used here, despite that it's correct.
Update issue 233.
2013-03-07 17:38:13 +01:00
Mike Hearn
0534231de9 Run wallet event listeners unlocked. Resolves another inversion.
Update issue 223.
2013-03-07 17:08:15 +01:00
Mike Hearn
97bce595c3 ToyWallet -> SPVBlockStore. 2013-03-06 13:47:51 +01:00
Mike Hearn
96cd35f139 Add a convenience method to CheckpointManager and example of how to use in PingService. 2013-03-05 14:48:28 +01:00
Mike Hearn
121695fa13 Use a shutdown hook to make sure everything is wrapped up nice and neat. It's not actually required in this example, but it's good practice. 2013-03-05 14:48:28 +01:00
Mike Hearn
20fdc72ab2 Make PingService use SPVBlockStore. 2013-03-05 14:48:28 +01:00