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

1667 Commits

Author SHA1 Message Date
Mike Hearn
88c4918f93 Script: better comment. 2014-09-18 19:56:18 +02:00
Mike Hearn
40c73eeac2 Script: take out obsolete todo comment. 2014-09-18 19:56:18 +02:00
Mike Hearn
8d83f4d25b Bloom filtering: add a convenience BloomFilter.insert(ECKey) method. 2014-09-18 19:56:18 +02:00
Mike Hearn
843e785daf Bloom filtering: Add equals/hashCode/toString to FilteredBlock and PartialMerkleTree then unit test round tripping. 2014-09-18 19:56:18 +02:00
Mike Hearn
d94d5bee8e Try slightly more useful error log in NioClientManager.handleKey whilst still keeping it concise. 2014-09-18 19:56:18 +02:00
Andreas Schildbach
57bec6165b Parse verifyFlags from script and tx JSON tests. In addition to P2SH (previously known as enforceP2SH), NULLDUMMY is implemented.
Update all script and tx JSON tests from Bitcoin Core.
2014-09-13 23:28:57 +02:00
Andreas Schildbach
aa14af564e Reduce log level of marked/un-marked messages to debug. It produces huge log files. 2014-09-11 15:08:36 +02:00
Kosta Korenkov
e1a4af2052 MissingSigResolutionSigner works for raw multi-sig 2014-09-11 19:37:14 +08:00
Kosta Korenkov
77f414fc62 Signers: skip signing if input is fully signed already 2014-09-11 19:18:09 +08:00
Kosta Korenkov
cf5089697b Fix extra signature added to the full scriptSig 2014-09-11 14:51:34 +08:00
Andreas Schildbach
3e5e3496ea Introduce textual checkpoint format. It's basically one base64-encoded line per checkpoint.
The BuildCheckpoints tool now generates and sanity checks both formats.
2014-09-10 17:59:41 +02:00
Adam Mackler
34214533c9 Take only as much time as necessary to open circuits for peer-IP DNS lookups
This patch addresses two suboptimal behaviors in the `TorDiscovery` class:

1. Currently it uses the DNS-lookup timeout as the timeout for opening
   circuits as well as for actually looking up the IP numbers.  It may
   be this timeout value, which is five seconds hard-coded into the
   `PeerGroup` class, was not intended for this purpose.  Moreover,
   the `TorConfig` class has a value, circuitBuildTimeout, apparently
   for this purpose; at least its default of 60 seconds may be more
   appropriate for this purpose than the five-second lookup timeout.

2. Currently, the process of opening circuits for the DNS lookups will
   take exactly as long as the timeout value, no more, no less, which
   practically guarantees that the client will either wait longer than
   necessary, or else experience timeout errors that could have been
   avoided by waiting a bit longer.

The changes herein use the return value of`TorConfig.getCircuitBuildTimeout()`
as the timeout for opening circuits, rather than using the DNS lookup
timeout value that is passed by `PeerGroup` as an argument to
`PeerDiscovery.getPeers()`.  Moreover, as soon as a circuit either has
been opened or failed to be opened for each router, the DNS lookups
then begin without waiting for the timeout time to elapse.

Notes:

1. There are no tests with these changes.  There don't seem to be any
   tests for the `TorDiscovery` class.  There probably ought to be.

2. The `TorDiscovery` class's DNS lookup procedure has the same
   timeout characteristic as the one this patch removes from the
   circuit-opening procedure, namely it waits for as long as the
   timeout value, no more no less.  If the changes proposed in this
   patch are acceptable, I would consider making the same change for
   the process of looking up the peer IP numbers.
2014-09-10 13:19:47 +02:00
Kosta Korenkov
691de1d22b Signers: Share keypaths for watching wallets
Now LocalTransactionSigner populates ProposedTransaction.keyPaths map even if
there is no private key in the wallet. Other signers may take advantage
of that.
2014-09-10 13:08:49 +02:00
Mike Hearn
dc857f0d83 Postgres store: Simplify a redundant if conditional. 2014-09-10 13:02:47 +02:00
Kosta Korenkov
f4879e22a6 Signers: Share keypaths for watching wallets
Now LocalTransactionSigner populates ProposedTransaction.keyPaths map even if
there is no private key in the wallet. Other signers may take advantage
of that.
2014-09-09 23:26:14 +02:00
Kosta Korenkov
5910a7f25e Married wallets: multisig threshold could be specified
That allows to create multisigs like 3-of-3. If not specified, majority of
keys will be required (2-of-3, 3-of-5 and so on)
2014-09-09 14:23:32 +02:00
Andreas Schildbach
96107b8b91 Replace "poor man's (aka. really, really poor) JSON parser" by Jackson for the script and tx tests.
The tests semantics was unchanged. 161 lines of code removed.
2014-09-09 14:19:49 +02:00
Devrandom
1f39dcdc6f Always use position 0 for LocalTransactionSigner sig, we don't know in advance what position we'll end up in
Fix p2sh bloom filter construction
Proper signature insertion for P2SH scriptSig
2014-09-09 14:15:54 +02:00
Martin Zachrison
7cb795235d Fixed grammar 2014-09-09 13:29:22 +02:00
Martin Zachrison
63b4b179e0 Payment channel API. Negotiation af the channel duration.
1. Client requests a time window, in seconds relative to now.
2. Server suggests an expire time, absolute time in seconds
3. Client accepts or rejects the servers proposal.
Note that the IPaymentChannelClient.ClinentConnection interface has a new method. This will break old implementations.
Let the client request the duration of a payment channel. Server can set allowed time window.
2014-09-09 13:29:22 +02:00
Mike Hearn
f569e10c17 Peer: reindent lines to match code style. 2014-09-08 18:26:36 +02:00
Mike Hearn
2b01508e10 Peer: fix the case where dependency download is disabled. It wasn't sending transactions to the wallet before. Add a test for this and add accessors for the setting. 2014-09-08 18:24:44 +02:00
Andreas Schildbach
302bb3e21d Use the new Transaction.SORT_TX_BY_UPDATE_TIME comparator and refresh comments. 2014-09-08 13:08:21 +02:00
Andreas Schildbach
2b80e4cfd1 Update script JSON tests from upstream. 2014-09-08 13:07:03 +02:00
Andreas Schildbach
2aa7f25a95 Provide a more meaningful exception when reaching past end of ASN.1 stream. Properly close ASN.1 decoder in exception paths.
A way to trigger the exception is running ScriptTest.dataDrivenValidTransactions().
2014-09-08 13:07:03 +02:00
Mike Hearn
c8803bdefe WalletTest: Better unit test failure message to check if the test is flaky. 2014-09-08 13:01:07 +02:00
Adam Mackler
a3073a0017 Don't bother pointless attempt to construct thread pool with no open circuits. 2014-09-08 12:57:00 +02:00
Andreas Schildbach
56603ff1f9 Fix version message. My heart breaks when I see the bad spelling of our dearest child in the logs. 2014-09-08 12:38:24 +02:00
Kosta Korenkov
c2d19a31a8 Wallet throws on missing signature by default
Using dummy sigs by default may be confusing for multi-sig scenarios.
See: https://groups.google.com/forum/#!topic/bitcoinj/PEhZGk3WMxU
2014-09-05 12:06:55 +02:00
Andreas Schildbach
ae24da4f9c When manually constructing SimpleDateFormat, specify Locale.US or otherwise we may end up on non-latin scripts.
See SimpleDateFormat javadoc for a discussion.
2014-09-04 14:17:23 +02:00
Andreas Schildbach
9f6f630dfb Catch AssertionError when connecting to sockets.
Annoyingly this is thrown on Android when libcore.io.Posix.getsockname() throws libcore.io.ErrnoException, rather than just an IOException.
2014-09-04 12:51:57 +02:00
Mike Hearn
a0d72294a0 Fix a buggy log message and make the comment clearer. 2014-09-03 18:55:10 +02:00
Andreas Schildbach
7d930554a6 Support for recording a memo with transactions. It can be used to record the memo of the payment request that initiated the transaction. Use the new SendRequest.memo register. 2014-09-03 16:13:41 +02:00
Michael Bumann
d09b69ebc5 make DeterministicSeed constructors public 2014-09-02 20:54:01 +02:00
Mike Hearn
d185dd55f1 Try a tweak to the unit tests to make Travis happy. 2014-09-01 17:49:42 +02:00
Mike Hearn
ed75774605 Transaction.verify: make it throw VerificationException subclasses, and add a check for duplicated outpoints.
This check does not have any impact on existing apps as in full verification mode the UTXO set is already effectively performing this check, and general SPV wallets don't verify inputs meaningfully anyway (they could just be random). However it's useful for Lighthouse and can't hurt - a tx with a duplicated outpoint is always invalid.
2014-09-01 17:06:41 +02:00
Mike Hearn
4d18a477dd Transaction.addSignedInput: catch API usage error. 2014-09-01 15:33:58 +02:00
Kosta Korenkov
6579d72bd8 Add SendRequest.missingSigsMode
Instead of useDummySignatures flag there is now a MissingSigMode enum
allowing to specify what to do with missing signatures.

Available modes:
USE_OP_ZERO - do nothing. OP_0 will be left in place of missing
signature
USE_DUMMY_SIG - insert dummy signature in place of missing sig.
THROW - throw an exception. It would be either MissingSignatureException
for P2SH or MissingPrivateKeyException for other tx types

Default mode is USE_DUMMY_SIG (for backward compatibility)
2014-09-01 13:10:51 +07:00
Kosta Korenkov
dc83712d9d Fix DummySigSigner misplaces dummy sig in P2SH scriptSigs 2014-09-01 12:37:39 +07:00
Andreas Schildbach
b1176e0fdf Rename CoinFormat to MonetaryFormat, now that it can deal with Coin and Fiat mostly the same way. 2014-08-28 14:45:36 +02:00
Andreas Schildbach
5be769d4ca Support for applications recording exchange rate that was valid when transaction was sent. Use the new SendRequest.exchangeRate register.
Includes a test.
2014-08-28 14:32:26 +02:00
Mike Hearn
d9be6a62d2 Peer: Add a version handshake future. 2014-08-28 14:26:20 +02:00
Mike Hearn
0f48c902d2 Better warning messages for the block store rollback code. It was printing exceptions for replays and new wallets. 2014-08-26 11:46:39 +02:00
Andreas Schildbach
b4e1e2d9ef Remove debug output that slipped in with the last commit. 2014-08-25 15:22:01 +02:00
Andreas Schildbach
f3733cae3b Configure CoinFormat with values from a Locale. 2014-08-25 01:03:59 +02:00
Andreas Schildbach
9e91c54fdd Formatting and parsing of monetary values with non-arabic digits. 2014-08-25 01:03:57 +02:00
Kosta Korenkov
282c25eeb4 Signers: map derivation paths to scriptPubKeys..
.. instead of TransactionInput objects since latter are mutable.
2014-08-24 23:19:09 +02:00
Andreas Schildbach
ad6adea0c5 Overload Script.getToAddress() with a variant that tries harder to determine a destination address.
I ended up duplicating this piece of code several times, so I thought it may be useful to have it in the framework.

Includes tests.
2014-08-24 23:13:20 +02:00
Mike Hearn
308de4edc1 Fix or comment out a few Java 7isms. 2014-08-24 01:02:44 +02:00
Adam Mackler
e2b802235d Extension of java.text.Format for locale-sensitive Bitcoin value formatting & parsing. 2014-08-24 00:35:08 +02:00
Oscar Guindzberg
2bc8f952e2 Wallet docs: link to github.io not google code 2014-08-23 18:45:02 -03:00
Mike Hearn
46104903fb WalletAppKit: delete dead store. 2014-08-23 21:20:14 +02:00
Mike Hearn
03c8cf5927 Wallet: ban usage of wallet.importKey with deterministic keys. 2014-08-23 20:42:22 +02:00
Mike Hearn
fcdd0115c4 Slightly clearer comment and log message in Script.executeCheckSig. 2014-08-23 13:11:27 +02:00
Mike Hearn
729c716b18 WalletTest: pin creation time of wallet key hierarchy in keyRotationHD test to avoid timing race. Should resolve issue 575. 2014-08-23 13:11:05 +02:00
Andreas Schildbach
9546a13870 Fix spelling UTXOS -> UTXOs. 2014-08-22 23:43:01 +02:00
Andreas Schildbach
c8c30f8ec1 Add my testnet DNS seed. It runs sipas crawler, but rather than using its custom nameserver implementation it serves a generated zonefile via bind9.
FWIW, my domains are secured using DNSSEC.
2014-08-22 00:17:18 +02:00
Andreas Schildbach
8e5ab9356c Introduce Fiat as a holder for fiat values. Coin and Fiat share an interface Monetary so that monetary infrastructure can be re-used.
Adapt CoinFormat to be used with Monetary. Add an ExchangeRate value class that can convert from Coin to Fiat and back.
2014-08-21 15:10:27 +02:00
Andreas Schildbach
483b3bbc9b When a wallet is added to a block chain that has a lower block height than the chain, try to repair.
Adds a "crash simulation" unit test.
2014-08-21 13:49:46 +02:00
Kosta Korenkov
d8944b922f Make LocalTransactionSigner to sign P2SH inputs.
Transaction inputs are now prepopulated with empty scriptSig. Each signer
is expected to update this scriptSig with a signature at a proper place.
There is a new method in RedeemData to locate index of the key/signature
within scriptSig/program.
To generalize an above approach for all supported types of inputs,
RedeemData can now represent data for any type of input. For
pay-to-address and pay-to-pubkey inputs it is expected to contain single
key and CHECKSIG program.

Signers now accept ProposedTransaction object that could carry additional
metadata shared between signers. For now it shares derivation path of the
signing key.

To preserve the dummy sig feature, a new flag was introduced in a SendRequest.
It specifies whether to fill empty sigs with dummies during tx completion
or not. Default value is true (for backward compatibility).

There is a CustomTransactionSigner class that may be used as a base for
simple third-party signers (or may be not). It is used in unit test which
may be treated as a usage example.
2014-08-21 13:47:08 +02:00
Matt Corallo
b8e84ecdc7 Fix 100% CPU bug by clearing OP_CONNECT on connected key 2014-08-18 22:03:11 +00:00
Matt Corallo
ecd6afc7b7 Fix null getNewParser (again, and add test this time) 2014-08-18 14:11:47 -07:00
Matt Corallo
ff52164921 Stop overwriting OP_WRITE when writing in ConnectionHandler c'tor 2014-08-18 11:51:51 +02:00
Matt Corallo
d3003622f2 Handle getting a null from getNewParser gracefully 2014-08-17 14:24:59 -07:00
Kosta Korenkov
e2dbd2a3f7 Fix DeterministicKeyChainTest failing on Windows
Git changes line endings in files to CR+LF on Windows by default, while
protobuf always uses LF. That makes serialization tests fail.
2014-08-17 22:50:29 +07:00
Andreas Schildbach
4834fe6eb6 Remove TransactionConfidence.workDone. It doesn't seem useful and was somehow buggy. 2014-08-16 15:16:11 +02:00
Mike Hearn
9f8e09c5b4 HDUtils: less insistence on immutable params 2014-08-15 18:46:19 +02:00
Mike Hearn
1b92abe294 HDW: Add an AUTHENTICATION key purpose that's mapped to the internal chain. 2014-08-15 18:22:57 +02:00
Mike Hearn
f00aef2048 HDW: Add a getKeyByPath() method to wallet, and (experimental) sanity check precomputed keys before they're returned by the wallet API to guard against the potential of a bitflip in either the stored pubkey bytes, or the ECC precomputed tables. The chance of such a bit flip is small but such flips HAVE been seen in the wild against other bitcoin implementations, so it could happen to a bitcoinj user too. The consequences can be catastrophic (destroyed money) so best to try and do what we can. 2014-08-15 18:06:06 +02:00
Mike Hearn
f8bc4d544e HDW: Create/activate a new HD chain when a wallet is constructed if the passed KeyChainGroup is empty. This means you can back up a wallet immediately after construction even before you request a key. Thanks to Andreas for the suggestion. 2014-08-15 17:04:27 +02:00
Kosta Korenkov
e893894f50 Make RedeemData to sort keys.
So that these keys are stored in the same order they appear in redeem script. That would make easier for signers to locate signature position in scriptSig.
2014-08-15 11:35:15 +07:00
Mike Hearn
7ec75b3483 Fix typo in comment. 2014-08-13 16:11:13 +02:00
Mike Hearn
014438b456 Take out the redundant SigHashType parameter to wallet.signTransaction.
In the end the API evolved in such a way that changing this param isn't that useful. To do contracts you tend to work with transactions directly, and a Wallet subclass that needs to do special signing by default can override the signing engine used.
2014-08-13 14:57:43 +02:00
Mike Hearn
c1e79b442c Fix some thread safety issues with Bloom filtering.
This hasn't shown up in any bug reports, I just spotted them through reading the code.
2014-08-13 14:55:54 +02:00
Mike Hearn
e1f270f726 Revert "PeerFilterProvider methods are called with the lock already held, so just assert on that instead of locking again."
This reverts commit e888807dfd.
2014-08-13 14:47:15 +02:00
Kosta Korenkov
1ba5909687 Add method to derive new keys when queried by path
Added DeterministicKeyChain.getKeyByPath(List, boolean) allowing to
specify whether to create non-existing key or not
2014-08-13 11:09:36 +02:00
Mike Hearn
e888807dfd PeerFilterProvider methods are called with the lock already held, so just assert on that instead of locking again. 2014-08-12 18:32:51 +02:00
Kosta Korenkov
f6b2fa5a2b Pluggable signers: simple local KeyBag signer
Introduced pluggable signers notion. Instances of
TransactionSigner could be added into the wallet, so that they subsequently
applied to transaction to complete it.
Existing signing code (Transaction.signInputs) was refactored into
LocalTransactionSigner, which is always implicitly added to any wallet.

Related pull request: #157
2014-08-12 17:58:29 +02:00
Mike Hearn
4a9295ccde Fix duplicateDetached 2014-08-12 16:32:52 +02:00
Mike Hearn
a30cdfed0c Eliminate the duplicated parentTransaction field from TransactionInput/Output. 2014-08-12 15:44:59 +02:00
Matt Corallo
20447bc340 Fix error when using Block.verify() after the Block constructor
...which takes all the elements of the block as paramters.
2014-08-11 15:27:48 -07:00
Mike Hearn
5220fb5141 Hide some fields in PartialMerkleTree 2014-08-11 19:21:25 +02:00
Andreas Schildbach
19b73600c8 Remove comment. I could not find any divergence in the getResourceAsStream error handling. 2014-08-11 18:45:35 +02:00
ollekullberg
fe91dc9110 Payment channel extension should be able to be initialized in two steps:
* A constructor that only takes the wallet as an argument

* A setTransactionBroadcaster() which should be called when the Bitcoin network is ready

Motivation: Some wallets (MultiBitHD) does not use WalletAppKit, and starts with reading the wallet before initializing the bitcoin network.
Now these wallets can create the wallet (and the wallet file is read), and call the setter after the bitcoin network is up.
2014-08-11 18:43:18 +02:00
Mike Hearn
90492b61f7 Change printed format of the wallet to be less verbose and make wallet-tool not dump privkeys by default. 2014-08-11 18:26:23 +02:00
Mike Hearn
e8ba287029 HD wallets: experimental change to not trigger full lookahead when deriving keys. This allows a savvy app to get keys/addresses at startup fast, if they do so before starting up the peergroup (which wants all keys in the zone so it can calculate a Bloom filter). May be reverted if it causes trouble. 2014-08-11 17:53:33 +02:00
Mike Hearn
d824666c2f HD Wallets: fix a lookahead bug.
We were not previously triggering lookahead before calculating a Bloom filter, which means we might have missed transactions in some edge cases. Add a test to catch this and then fix up various unit tests to have fewer magic numbers and be more robust to changes.
2014-08-11 16:37:31 +02:00
Mike Hearn
54a543bf77 HDW: Fix the case of wallet upgrades where the aesKey is provided. 2014-08-11 15:03:07 +02:00
Mike Hearn
00a276f906 HDW: Simplify an unusual for loop in DKC 2014-08-11 14:17:21 +02:00
Mike Hearn
53aa33c2e8 HDW: Clear some static analysis warnings from DKC. 2014-08-11 14:15:06 +02:00
Kosta Korenkov
0d2fb93536 Introduce MultisigKeyBag to expose P2SH redeem data
For married wallets KeyChainGroup now keeps redeem scripts together with keys
2014-08-11 11:34:20 +02:00
Devrandom
588e314b06 Fix failed precondition in maybeLookaheadScripts 2014-08-11 11:22:06 +02:00
Devrandom
2d3bfc07c7 Fix issue with deserialization and currentAddresses 2014-08-11 11:22:06 +02:00
Andreas Schildbach
a3ced5fe5d Consistently use version 2.8 of maven-dependency-plugin. 2014-08-11 11:18:09 +02:00
Andreas Schildbach
165b0cfbf7 Consistently use version 2.6 of cobertura-maven-plugin. 2014-08-11 11:18:09 +02:00
Andreas Schildbach
fd4ec21dcc Consistently use version 2.1.2 of maven-source-plugin. 2014-08-11 11:18:09 +02:00
Andreas Schildbach
415e43885c Consistently use version 2.3 of maven-shade-plugin. 2014-08-11 11:18:09 +02:00
Andreas Schildbach
8e24ee865f Update to and consistently use version 2.5 of maven-jar-plugin. 2014-08-11 11:18:09 +02:00
Andreas Schildbach
80e2d46ed0 Update to and consistently use version 2.5.1 of maven-install-plugin. 2014-08-11 11:18:08 +02:00
Andreas Schildbach
43a6a60bea Consistently use version 1.2 of maven-enforcer-plugin. 2014-08-11 11:18:08 +02:00
Andreas Schildbach
2324edd03e Consistently use version 3.1 of maven-compiler-plugin. 2014-08-11 11:18:08 +02:00
Andreas Schildbach
549f228d29 Assume wordlist will be 2048 words in size. 2014-08-06 19:10:14 +02:00
Andreas Schildbach
761b06fb8a Fix handling of mnemonic class resource not found. It was falsely assumed that Class.getResourceAsStream() would throw. 2014-08-06 19:10:14 +02:00
Mike Hearn
32a5ed3f21 Don't roll back progress measurement when download peer changes in DownloadListener. 2014-08-06 19:04:28 +02:00
Mike Hearn
249d547ee3 Check for loading wallet of wrong params in deserializer (in another way so people who use the API at a lower level also get checked) 2014-08-06 18:21:31 +02:00
Mike Hearn
925338b4fc Bump Tor timeout to 60 seconds. 2014-08-06 18:21:08 +02:00
Mike Hearn
4ae6349f35 Fix for Android ART vs Dalvik difference. 2014-08-06 16:40:13 +02:00
Mike Hearn
e41e0c4a1d Allow usage of signMessage for deterministic keys. 2014-08-06 16:26:48 +02:00
Mike Hearn
047c5ccd03 WalletAppKit: configure Orchid/Tor to use the same directory as bitcoinj uses. 2014-08-06 16:12:41 +02:00
Mike Hearn
96e4774e79 Add support for fetching UTXOs from a peer using the getutxo message. 2014-08-06 13:43:51 +02:00
Mike Hearn
bca2f2abac Make Wallet.queue* methods protected so subclasses can call them. 2014-08-06 13:43:31 +02:00
Kosta Korenkov
5cfdca1c98 Add ability to create scriptSigs with empty signatures
For partial scriptSig OP_0 is used as a signature placeholder:
Pay-to-address: OP_0 [pubkey]
Pay-to-pubkey: OP_0
P2SH with 2-of-3 CHECKMULTISIG: OP_0 OP_0 OP_0 [redeem script]
2014-08-05 20:49:40 +02:00
Martin Zachrison
bc97cf977f Handle creation of non existing parent directories. Improve exception message. 2014-08-05 17:36:04 +02:00
Mike Hearn
0a7fdf35ba Add some junk to the POM to create a dedicated bundled JAR for the pull tester. 2014-08-05 16:48:58 +02:00
Andreas Schildbach
918665a6e4 Work done can never be negative. Assert for that fact, because we've seen negative values in the wild. 2014-08-05 12:34:57 +02:00
Kosta Korenkov
fa3037a4b2 Fix KeyChainGroup.toString double keys output 2014-08-05 12:34:18 +02:00
Andreas Schildbach
299879c418 Allow fallback URLs for BIP72 payment request fetching. Adds unit tests. 2014-08-04 14:30:59 +02:00
Mike Hearn
e03f184a1f PaymentProtocol: fix seconds vs milliseconds confusion. Thanks to Adam Mackler for the bug report. 2014-08-03 21:06:15 +02:00
cyberzac
eff9ac2ecc Support for bundling an optional info Protobuf ByteString with a PaymentAck message 2014-08-03 21:02:40 +02:00
Mike Hearn
f1dd47443f More hashes for the dependency verifier, also request version divergence detection. Bump JSR350 jar version. 2014-08-03 20:52:22 +02:00
Mike Hearn
fe6f5aff01 Payment channels: ByteString.EMPTY -> null 2014-07-31 16:18:48 +02:00
cyberzac
1153192be8 Support for bundling an optional info Protobuf ByteString with an UpdatePayment message. 2014-07-31 16:01:38 +02:00
Mike Hearn
9e56093353 ConnectionHandler: Make comment a bit clearer. 2014-07-31 15:55:24 +02:00
Matt Corallo
c5cb306927 Fix memory leak on timeout in NioClient 2014-07-31 15:53:23 +02:00
Matt Corallo
5f5700bbb0 Fix race between connectionClosed() and ConnectionHandler() 2014-07-31 15:53:22 +02:00
Mike Hearn
4dc3392719 Fix Java 6 compatibility. 2014-07-31 15:53:14 +02:00
Mike Hearn
0f124b9ef4 Add some javadocs for Wallet.fromWatchingKey 2014-07-30 12:06:16 +02:00
eleetas
914752623d close connection regardless of autocommit status and set conn to null 2014-07-30 11:25:55 +02:00
Mike Hearn
d681c72b30 Fix typo 2014-07-30 11:09:56 +02:00
Carlos Lopez-Camey
12e1c3f6bd Improve javadocs, revert unnecessary unmodifiable list 2014-07-29 12:31:08 -06:00
Carlos Lopez-Camey
ce7520b0c8 Merge branch 'master' of https://github.com/bitcoinj/bitcoinj 2014-07-29 12:23:42 -06:00
Mike Hearn
6679f42f4a Use a local Bitcoin node if one is detected instead of the p2p network. This allows any user of a bitcoinj based app to upgrade from SPV to full mode security by just installing and running Core on the same machine. Can be controlled with a new property on PeerGroup. 2014-07-29 18:13:52 +02:00
Mike Hearn
812a4f59c4 Re-allow Android devs to override the mnemonic code instance. 2014-07-28 16:13:12 +02:00
Carlos Lopez-Camey
40709495fc Merge branch 'master' of github.com:kmels/bitcoinj 2014-07-27 13:19:06 -06:00
Carlos Lopez-Camey
e208430ab6 adds helper methods Transaction.getWalletOutputs, TransactionOutput.getAddressFromPubKey and TransactionOutput.getAddressFromScript. 2014-07-27 13:15:20 -06:00
Mike Hearn
539037ec0e Switch to accelerated secp256k1: huge speed improvements. 2014-07-26 14:56:34 +02:00
Mike Hearn
6ae4662f93 Upgrade to Bouncy/Spongy Castle 1.51 2014-07-26 14:48:51 +02:00
Kosta Korenkov
55803b15ac Fix Script.getNumberOfBytesRequiredToSpend for P2SH
It is a size of redeem script that should be taken into account, not a
size of scriptPubKey
2014-07-26 01:05:22 +04:00
freak
b2efb0ddc2 Close connections in PostgresFullPrunedBlockStore. same as: b6f61e8850 2014-07-23 16:10:45 +02:00
Jiri Peinlich
cb0d052e08 use List interface instead of LinkedList implementation 2014-07-23 16:08:36 +02:00
Andreas Schildbach
c6659bcf5f BIP38: Fix test using supplementary characters in the passphrase. 2014-07-23 16:07:26 +02:00
Mike Hearn
4a45d4a27f Print full backtrace when a wallet extension fails to load. 2014-07-23 15:40:14 +02:00
Mike Hearn
afb732c528 Restore new tx purposes correctly. 2014-07-22 16:11:29 +02:00
Mike Hearn
626117bc29 Add logging for output disconnection and reconnection. 2014-07-22 16:04:26 +02:00
Mike Hearn
92544e9d47 Add ASSURANCE_CONTRACT_CLAIM/PLEDGE/STUB to the purpose field. 2014-07-21 16:42:20 +02:00
Mike Hearn
a5e4d046df Adjust the behaviour of the current key mechanism to be more like what gui wallets really need. 2014-07-15 20:55:23 +02:00
Mike Hearn
96ee76e506 Update bip38 test3 ignore message again now the problem is better understood. 2014-07-15 20:52:08 +02:00
Mike Hearn
e143b2b4cb Re-organise the layout of the Wallet file and introduce IntelliJ compatible editor regions, so parts of the code can be folded by feature area. This also makes it easier to understand what exactly the wallet does and why it's so huge. 2014-07-15 17:14:59 +02:00
Mike Hearn
b6c1e385c0 Update wallet todo list. 2014-07-15 16:31:03 +02:00
Giannis Dzegoutanis
5e1942f3f0 Made some methods public in BasicKeyChain. Fixes in deterministic key generation 2014-07-15 16:24:53 +02:00
Andreas Schildbach
72b7929523 Getter for addresses watched by wallet. 2014-07-15 14:42:20 +02:00
Andreas Schildbach
15060572a9 Fix some exception messages in BIP38PrivateKey. 2014-07-15 14:06:25 +02:00
Mike Hearn
0addfd63ec Fix reason why BIP38 test vector is failing, Java strings can contain null characters just fine. 2014-07-15 14:05:04 +02:00
Mike Hearn
bab16650f9 HD Wallets: fix key lookahead and auto-advance so it works as intended.
Previously the codepath that was supposed to mark keys as used didn't work, and the lookahead calculation wasn't quite right. Now the current key advances correctly when an inbound tx is found that spends to it, including pending transactions. Additionally the lookahead zone now has the threshold zone after it, not inside it, meaning that if you request a lookahead size of 100 keys you'll actually always have at least 100 keys, never less.
2014-07-15 13:41:45 +02:00
Aaron Voisine
89b4b78dc4 fixed MAX_STANDARD_TX_SIZE to match bitcoin core
in bitcoin core MAX_STANDARD_TX_SIZE is 100000, not 102400

https://github.com/bitcoin/bitcoin/blob/master/src/main.h#L43
2014-07-14 16:19:53 -07:00
Andreas Schildbach
8068230042 Remove superfluous AddressFormatException from BIP38PrivateKey.decrypt(). 2014-07-13 22:10:28 +02:00
Andreas Schildbach
aaf349ea6a Fix Java7'ism. 2014-07-13 22:10:11 +02:00
Mike Hearn
78383f98f4 WalletAppKit: support for restoring a wallet from a seed. The old wallet is moved out of the way. 2014-07-11 00:26:37 +02:00
Mike Hearn
68bb476430 Clear an NPE in wallet printing that could occur when printing a wallet with private keys included. 2014-07-10 21:58:27 +02:00
Mike Hearn
8e6e2256bc WalletAppKit/Template: Cleaner way to check if the app is already running. Backport from Lighthouse. 2014-07-10 21:44:38 +02:00
Mike Hearn
13b2f2104c Less debug spam when sending bloom filters to keep FP rate low. 2014-07-10 21:38:32 +02:00
Mike Hearn
46d4c3487e Generalise the crypto DRM workaround and use from the BIP38 codepath too. 2014-07-10 15:33:47 +02:00
Mike Hearn
682bd035fc Fix a couple of static method via instance warnings. 2014-07-10 15:33:10 +02:00
Andreas Schildbach
a750a14edd Implement BIP38 password encrypted private keys, decryption only. Contains all the test vectors from the spec minus one that is incompatible to Java. 2014-07-10 14:57:25 +02:00
Justas
03652298e1 Dead transaction does not contain confidence depth and should not fail when sorting. 2014-07-10 14:56:47 +02:00
Giannis Dzegoutanis
9446b1b625 added test for HDUtils.formatPath and changed HDUtils.parsePath to handle paths that start with the letter M 2014-07-10 14:56:10 +02:00
Devrandom
fec6cbc7df Remove support for mnemonic-less keychains 2014-07-10 14:53:42 +02:00
Devrandom
2fae12064c Fix BIP39 implementation 2014-07-10 14:53:42 +02:00
Devrandom
3420bdf8ac Add cobertura support 2014-07-10 14:53:42 +02:00
Mike Hearn
483fd8a908 Expose TransactionBroadcast.random 2014-07-09 13:07:56 +02:00
Andreas Schildbach
c7fe06d4c7 Fix java package of ExponentialBackoffTest. 2014-07-08 13:54:05 +02:00
Mike Hearn
f7070df152 Allow TestWithNetworkConnections subclasses to override the wallet with their own. 2014-07-07 16:18:51 +02:00
Andreas Schildbach
afcc7e3f13 Coin.toFriendlyFormat() includes denomination (BTC). This saves a lot of string concatenation code. 2014-07-05 21:03:51 +02:00
Andreas Schildbach
794263436f Add ability to prefix or postfix currency codes when formatting coins. Defaults are BTC, mBTC and µBTC. 2014-07-05 21:03:51 +02:00
Andreas Schildbach
d22ee01f8a Fix ECKey.equals() and toString() to also include encryptedPrivateKey. Convert to Guava and consolidate at bottom of class. 2014-07-05 18:14:16 +02:00
Mike Hearn
bb40036453 Fix a payment protocol unit test that had a forgotten @Test annotation and thus didn't actually work. 2014-07-05 17:27:22 +02:00
Andreas Schildbach
5580fd9d92 Make DumpedPrivateKey serializable, so that it can be used to pass around keys between loosely coupled application components. 2014-07-05 15:14:22 +02:00
Andreas Schildbach
48d748d2be Auto-upgrade to HD when fetching a change address. 2014-07-04 16:24:23 +02:00
Devrandom
bbe983f38a relax assumption that HD seeds are 128 bits
cleanup
2014-07-03 14:07:05 -07:00
Devrandom
39d8da6764 relax assumption that HD seeds are 128 bits 2014-07-02 14:39:32 -07:00
Mike Hearn
009b04551a Update the documentation for Transaction.hashForSignature to note a quirk of P2SH outputs. 2014-06-28 19:01:29 +02:00
Oscar Guindzberg
1d5058626a Peer.blockChainDownloadLocked() - fix getblocks message documentation 2014-06-28 14:55:21 +02:00
Oscar Guindzberg
d1c3be126d PeerGroup.startBlockChainDownload(): add the supplied listener to the
downloadingPeer
2014-06-28 14:49:21 +02:00
Kosta Korenkov
12bfa5f5ee Married wallets: extending fee calculation 2014-06-28 14:36:05 +02:00
Giannis Dzegoutanis
fd0c6a27f4 added a helper function to parse human readable deterministic paths 2014-06-28 14:35:48 +02:00
Mike Hearn
dbd6004f1b HD Wallets: redo key rotation, it's no longer automatic and expects the wallet app to poll for maintenance transactions. Deterministic keys now inherit the creation time of their parent. 2014-06-26 16:21:23 +02:00
Ximo Guanter
b6f61e8850 Close connections in H2FullPrunedBlockStore 2014-06-26 15:25:47 +02:00
troggy
736c4c9907 Married HD wallets: Bloom filter adjustments
Pull request: #115
Based on design notes:
https://groups.google.com/forum/#!msg/bitcoinj/Uxl-z40OLuQ/e2m4mEWR6gMJ
2014-06-26 14:45:03 +02:00
Kosta Korenkov
2edf978af4 Rename addFollowingAccounts -> addFollowingAccountKeys 2014-06-25 01:18:53 +04:00
Mike Hearn
32360fea8d Give regtest mode its own ID so wallets don't get mixed up between regtest and testnet. 2014-06-24 18:37:19 +02:00
Mike Hearn
09286a932c Remove some superfluous new String() calls around HEX.encode, now it has a sane API. 2014-06-24 14:11:09 +02:00
Mike Hearn
704575df1c Add a forgotten @Test annotation and fix the expected exception type. 2014-06-23 16:18:46 +02:00
Mike Hearn
11d8d57a1a Wallet: remove a few dead stores identified via static analysis. 2014-06-23 15:39:33 +02:00
Mike Hearn
f2f64d1e80 Wallet: move setTag to the extensions section of the file. 2014-06-23 15:37:52 +02:00
Andreas Schildbach
e9c777c9a6 Explain why a transaction output value is kept as a long rather than Coin. 2014-06-23 15:23:08 +02:00
troggy
e192f9030c Prevent marriage of used keychain
addFollowingAccounts method now has the check that active keychain has no keys in use. This would prevent divergence of derivation paths for followed and following keys. In future this behaviour should be replaced with some sort of key rotation.
2014-06-23 14:53:09 +02:00
troggy
9dbc507fca Improvement of getFollowingKeys
First of all, freshAddress was actually asking for a fresh key twice for non-married keychain. That was fixed by moving first call (needed only for married chain) inside the getFollowingKeys. As the latter now started to return all keys in a marriage and not only following ones, it was renamed to freshMarriedKeys.
Having all the keys in one block allows to do simple derivation path check to make sure keychains are in sync (as per @devrandom suggestion)
2014-06-23 14:53:09 +02:00
troggy
06755aefde Married HD wallets: introduce shadow keychain notion
Pull request: #99
Based on design notes:
https://groups.google.com/d/msg/bitcoinj/Uxl-z40OLuQ/e2m4mEWR6gMJ
2014-06-23 14:53:09 +02:00
Adam Mackler
b7cb4d8c47 TransactionOutput class private value member changed to type long from Coin. 2014-06-23 13:49:08 +02:00
Adam Mackler
e8048cb672 Changes to the Coin class: some convenience comparison operators;
`parseCoin()` now accepts negative values; the check for an excessive
value is moved to the constructor from `parseCoin()` and uses
`checkArgument()`; some `Coin`-type constants broken out into one
`long` one `Coin` in order to be usable in the constructor.
Corresponding tests included.  The `BitcoinURI` class constructor
throws exception on parsing a negative amount, which is needed now
that `Coin` class accepts negative amounts.
2014-06-23 13:49:08 +02:00
Devrandom
e2ebe69aae Fix key derivation 2014-06-22 12:47:27 -07:00
Piotr Włodarek
3dfaf54e28 Fixed VarInt serialization bug for the 0xffffffff number. Fixed VarInt sizeOf bug for the 0xffffffff number and added tests for VarInt edge cases.
The 4294967295 number (0xffffffff) was incorrectly serialized because the UnsignedInteger.MAX_VALUE.longValue() helper returned 4294967295 instead of expected 4294967296.

The VarInt.sizeOf() incorrectly returned 9 instead of 5 for the 4294967295 (0xffffffff) number.

See https://en.bitcoin.it/wiki/Protocol_specification#Variable_length_integer
2014-06-20 16:35:33 +02:00
Andreas Schildbach
ae3acdfefd Remove undefined arithmetics method. 2014-06-20 14:57:55 +02:00
Mike Hearn
292a180926 Full mode test generator: use OP_NOP in inputs instead of OP_TRUE to avoid unclean stacks after execution. Additionally, reduce the verbosity of the code somewhat. There's still plenty that could be done to make the code cleaner but .... not today. 2014-06-18 12:21:54 +02:00
Mike Hearn
523b3018cb HD Wallets: do auto upgrade when possible on all inbound codepaths, and make DeterministicUpgradeRequiresPassword extend RuntimeException. 2014-06-17 16:20:38 +02:00
Andreas Schildbach
7f68c3472f Add SendRequest.toString(). 2014-06-17 12:47:34 +02:00
Andreas Schildbach
f86463bab3 Harmonize how BTC values are printed to the log by Wallet.completeTx(). Also, print the value that is emptied. 2014-06-17 12:47:34 +02:00
Andreas Schildbach
f4d24bffb1 Add SendRequest.signInputs flag to allow skipping the signing. It takes a long time and is not needed for when you only want to determine the fee. 2014-06-17 12:47:34 +02:00
Andreas Schildbach
9d1b15612a Fix a bug because the SendRequest.fee field is written to 0 when SendRequest.emptyWallet is used. Missing tests for this case are added.
Use SendRequest.tx.getFee() to get the fee, rather than reading SendRequest.fee.
2014-06-17 12:47:34 +02:00
Mike Hearn
443d556909 HD Wallets: implement auto upgrade behaviour and refresh the design doc. 2014-06-13 14:11:51 +02:00
Mike Hearn
57105f52e6 Fix redundant expression in MnemonicCode. 2014-06-12 20:26:30 +02:00
Andreas Schildbach
7a689fce3d Add Alexykot's test net DNS seed. Tested using Bitcoin Wallet, works fine. 2014-06-12 12:36:34 +02:00
Oscar Guindzberg
bd2536048a Make Transaction comparators compatible with equals 2014-06-12 12:17:24 +02:00
troggy
b40b3a5f9d Fix failing WalletProtobufSerializerTest 2014-06-12 11:25:53 +02:00
troggy
5840c8a66a Fix failing deserialization of wallet with an empty HD chain
Error occurred when deserializing wallet if either internal or external
zero account key chain of this wallet has no keys issued
2014-06-12 11:23:17 +02:00
Mike Hearn
b5911c1ee4 Add a missing lock on BasicKeyChain.getBloomFilter 2014-06-11 16:49:35 +02:00
Adam Mackler
40bc6f4c46 Add a method to deserialize a DeterministicKey from a byte-array rather than from the base-58 encoding thereof. 2014-06-11 16:20:26 +02:00
troggy
2a8454a85c HD wallet: currentKey is now stable after serialization roundtrip
At the moment currentKeys map of KeyChainGroup is not restored after
deserialization and subsequent call to currentKey produces different
key then expected.
Proposed solution reconstructs currentKey map on deserialization using
stored numbers of issues keys. It is
not future-proof as it assumes only RECEIVE and CHANGE keys are being
used.
2014-06-11 11:45:15 +02:00
Piotr Włodarek
9f25af54ab Fixed bitcoinj DoS. It could have been crashed by a malicious message.
Bitcoinj can be crashed with OutOfMemory by sending a message with
a large claimed var_str length or bytes array length.

The actual message size does not matter, it's the claimed length that matters.

This affects all bitcoinj-based apps that receive messages including Multibit, Android Bitcoin Wallet, Mycelium and Hive.

The fix limits accepted length to max message size (32 MB).

Signed-off-by: Mike Hearn <mike@plan99.net>
2014-06-10 18:50:19 +02:00
Andreas Schildbach
9befd32200 Allow zero repetitions for CoinFormat.repeatOptionalDecimals(). Also add tests. 2014-06-10 16:04:45 +02:00
Andreas Schildbach
fc923f8473 Remove unused CouldNotAdjustDownwards. Move JavaDoc to the real one. 2014-06-10 12:06:02 +02:00
Andreas Schildbach
fb4aab3edc Copy @throws from the JavaDoc of Wallet.completeTx() to all calling methods. 2014-06-10 12:06:02 +02:00
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