3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 07:12:17 +00:00
Commit Graph

1540 Commits

Author SHA1 Message Date
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
ff54085129 Add Mike to the AUTHORS file. 2013-11-30 15:15:37 +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 Hearn
0044c8d269 Add Mike Rosseel to the AUTHORS list 2013-11-27 18:05:14 +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
Mike Hearn
f519590973 Add wallet-template file I forgot to check in 2013-11-26 23:17: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
95fc6d7245 WalletTool: recognize private key format properly.
Resolves issue 390.
2013-11-24 19:10:56 +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
2bca8e858b Add Ken to the AUTHORS file. 2013-11-19 17:38:27 +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