Commit graph

2649 commits

Author SHA1 Message Date
Andreas Schildbach
2288c2150f PeerGroup: Make private walletCoinsReceivedEventListener also take care of P2WPKH outputs.
P2WPKH outputs are a similar case as P2PK outputs in that inputs that spend them
cannot be matched by a bloom filter: their scriptSig is empty and their witness
(which would contain a matching pubkey) is not tested for a match. This is a
shortcoming of the SegWit spec.

Hopefully this fixes https://github.com/bitcoinj/bitcoinj/issues/1690
2019-10-01 21:44:46 +02:00
Andreas Schildbach
7f97c8afa6 Change wording p2pubkey to P2PK. 2019-10-01 20:33:07 +02:00
Sean Gilligan
619e8805d6 Wallet: Improve JavaDoc for Wallet#commitTx and Wallet#maybeCommitTx. 2019-09-11 11:04:17 +02:00
Andreas Schildbach
a8230ad495 Peer: Wrap log.debug() in log.isDebugEnabled(). 2019-08-31 22:29:05 +02:00
Andreas Schildbach
1fbd280f14 AbstractBlockChain: Wrap log.debug() in log.isDebugEnabled(). 2019-08-31 22:28:26 +02:00
Andreas Schildbach
8db6639cf4 Peer: Raise log level when logging the setting of a filter. 2019-08-31 21:54:46 +02:00
Andreas Schildbach
726c7291ac Wallet: Remove global coinSelector and allowSpendingUnconfirmedTransactions().
Coin selection is a per SendRequest, per createSend() or per getBalance() call affair.
Having it wallet-global can lead to race conditions, as sometimes experienced in the
WalletTest unit tests.
2019-07-26 20:30:27 +02:00
Andreas Schildbach
a49f681d24 KeyCrypterScrypt: Print all Scrypt parameters, not only N. 2019-07-20 17:28:53 +02:00
Andreas Schildbach
1e55d72dc3 SendRequest: Add allowUnconfirmed() convenience method. 2019-07-15 12:26:14 +02:00
Andreas Schildbach
161bd68dd2 DefaultCoinSelector: Make it a singleton. 2019-07-15 12:07:27 +02:00
Andreas Schildbach
d67f060e27 Remove Micropayment Channels.
Now that HTLC-based bi-directional payment channels are state of the art, nobody will ever use the old style.
2019-07-15 11:05:14 +02:00
Sean Gilligan
e5a6808fd3 HDPath: M() and m() factory methods
Refactor existing of() factory methods to M() (for public key) and
add m() methods for private keys. Also add varargs methods.
2019-07-10 15:46:21 +02:00
Sean Gilligan
823a03db77 Move HDPath methods from HDUtils to HDPath
All HDPath-related methods in HDUtils are now deprecated and delegate
to HDPath. HDPath now contains parsePath code.
2019-07-07 10:13:26 +02:00
Sean Gilligan
b59add47a7 DeterministicKey: toString() output of creation time now corresponds with
getCreationTimeSeconds(), but we indicate if the creation time was inherited
from the parent.
2019-07-05 22:55:31 +02:00
Sean Gilligan
855c061c0c HDPath: Use varargs for extend() and add tests. 2019-07-05 22:40:38 +02:00
Sean Gilligan
a9dd62e34e Replace deprecated Guava Maps.newHashMap()
For JDK7+ `new` with the diamond syntax is preferred.
2019-07-05 12:08:14 +02:00
Sean Gilligan
ba922a910a Fix NPE in o.b.c.Utils runtime and os detection
If getProperty returns null calling toLowerCase results in NPE. Instead
we’ll use a default value and check for .equals(“”) in the following if.
2019-07-02 21:08:27 -07:00
Sean Gilligan
035839fdbf StoredBlock: Mark two constants as private. 2019-06-23 18:20:35 +02:00
Sean Gilligan
b9d88e20ef AbstractBlockChain: Fix typos in JavaDoc. 2019-06-23 18:12:42 +02:00
Sean Gilligan
474700ff50 StoredBlock: Add JavaDoc for constructor. 2019-06-23 18:11:43 +02:00
Sean Gilligan
99b019e5b0 New HDPath type to replace ImmutableList<ChildNumber>. 2019-06-23 14:20:15 +02:00
Sean Gilligan
3c5744a6cb AppDataDirectory: Move from wallettemplate/.utils to core/.utils
This allows usage in both wallettemplate and tools and replaces
similar code in BlockFileLoader.java in core.
Requires minor back-port of Path.of() functionality from JDK11.
2019-06-20 10:09:21 +02:00
Sean Gilligan
ebc59d06c6 MissingSigResolutionSigner: Make the missingSigMode member private and final. 2019-06-17 10:37:33 +02:00
Sean Gilligan
ea26e6bd26 StoredBlock: Make member fields final. 2019-06-12 11:44:40 +02:00
Cameron MacKeen
42cc626717 Transaction: Fix typos in JavaDoc. 2019-06-04 12:11:20 +02:00
Sean Gilligan
806afa0441 Replace Guava newArrayList()/newLinkedList() with direct call to the JDK 7 constructor.
This is recommended by deprecation comment in Guava.
2019-06-01 13:58:11 +02:00
Andreas Schildbach
05ab09b40b ECKey: Fix JavaDoc encoding error on Windows. 2019-05-30 09:10:06 +02:00
Andreas Schildbach
18f9108c6b LegacyAddress: Remove deprecated methods. 2019-05-25 15:39:16 +02:00
Premek
10607fb9f5 AbstractBlockChain: Try connecting orphans more often in add().
This fixes a memory leak.
2019-05-25 15:27:13 +02:00
Matthew Leon
56a44661b6 ScriptPattern: Remove redundant opcode check in isSentToMultisig().
The following line has a check that is strictly stronger.
2019-05-24 15:46:04 +02:00
Matthew Leon
b385e9ed2f ScriptPattern: In isSentToMultisig() replace exception flow by conditional. 2019-05-24 15:40:14 +02:00
Matthew Leon
b51922dde7 ScriptPattern: Correct and clarify the JavaDoc on isSentToMultisig() 2019-05-24 15:35:49 +02:00
Matthew Leon
30e21ea3a0 ScriptChunk.decodeOpN: Remove checkState().
The checkState() on ScriptChunk.decodeOpN() was excessively strict: it excluded OP_0. As the method calls Script.decodeFromOpN(), which itself has a check on the passed-in opcode, we simply remove the check entirely.

No code in bitcoinj was calling ScriptChunk.decodeOpN().
2019-05-21 08:51:25 +02:00
Matthew Leon
735b9143d2 Script: Simplify P2SH pushdata check in correctlySpends().
Simplify the check that all P2SH script content is comprised of pushdata operations, and give a clearer error message when this is not the case.
2019-05-20 10:33:40 +02:00
Matthew Leon
5647f48b0d ScriptChunk: Kill startLocationInProgram.
The startLocationInProgram field of ScriptChunk was used as a caching mechanism for storing the location of each ScriptChunk in a Script. This was memory-inefficient, as this integer was only actually used during interpretation of OP_CODESEPARATOR. Furthermore, it was dangerous and inconsistent: the ScriptBuilder methods, for example, do not properly set startLocationInProgram, leading to a potential runtime failure when interpreting ScriptBuilder-constructed Scripts.

Rather than caching each chunk's location, we add a method called size() that efficiently returns the size of a serialized ScriptChunk. During Script interpretation, we use this method to track the program counter.

Additionally, we add an exhaustive test to ensure that size() properly returns the size of a serialized ScriptChunk.

This will break any code that relied on ScriptChunk.getStartLocationInProgram().
2019-05-19 20:01:06 +02:00
Matthew Leon
0afaaad79a ScriptChunk: Fix IllegalArgumentException in toString() for invalid chunks.
Also see https://github.com/bitcoinj/bitcoinj/issues/1860
2019-05-19 19:51:26 +02:00
Matthew Leon
03f9e94824 ScriptOpCodes: Accept OP_FALSE and OP_TRUE in getOpCode().
Previously, only "OP_0" was accepted as the name for the 0x00 opcode. Similarly, only "OP_1" was accepted for 0x51.
2019-05-19 18:57:00 +02:00
Andreas Schildbach
ab2fb2f9cf KeyChainGroup: New CurrentKeyChangeEventListener that fires when a current key and/or address changes.
This also changes wallet-template to make use of the new listener for updating its current address in the UI.
2019-05-19 08:23:39 +02:00
Matthew Leon
cae0b385a4 ScriptChunk: Add missing @Nullable annotations to constructors. 2019-05-17 11:13:55 +02:00
Matthew Leon
e2e763bd33 ScriptChunk: Fix immutability. 2019-05-17 11:06:50 +02:00
Matthew Leon
67722ff0e8 ScriptOpCodes: Use the Guava BiMap interface to make the relationship between opCodeMap and opCodeNameMap explicit. 2019-05-17 11:00:39 +02:00
Matthew Leon
ce0509d97f TransactionWitness: Simplify toString() and make it more efficient. 2019-05-14 08:36:41 +02:00
Andreas Schildbach
6b3a4810c6 Script: Remove mention of 'from addresses' in comment. 2019-05-11 11:46:21 +02:00
Matthew Leon
13f350d9e1 ECKey: Update an outdated comment about the priv and pub fields.
Pub is always set. It just uses a lazy class.
2019-05-09 17:09:18 +02:00
Matthew Leon
09c8a8e855 ECKey: Missing @Nullable on priv field. 2019-05-05 21:46:16 +02:00
Matthew Leon
b1baf58268 SegwitAddres: Fix broken JavaDoc links.
These were broken by d4df1119de.
2019-05-05 19:51:36 +02:00
Andreas Schildbach
d4df1119de SegwitAddress: Import Script rather than Script.ScriptType. 2019-05-05 16:59:28 +02:00
Matthew Leon
c87f4b3f77 SegwitAddress: Don't encode witness version to OP_N when constructing.
This bug was never exposed outside the SegwitAddress class (and thus can't be tested) because the encode method is only ever called by fromHash, where the script version is always set to 0.

Nevertheless, this bug could result in faults in future code, as other witness program versions begin to be used: The other construction methods, such as fromBech32(), leave the version byte as a simple representation of the version number. This means that, were the SegwitAddress constructor ever called with a non-0 version number, getWitnessVersion() would return an incorrect result, and ScriptBuilder.createOutputScript() would fail, re-running encodeToOpN() on the now greater-than-16 version byte.
2019-05-05 10:49:14 +02:00
Andreas Schildbach
106e2c8baa Use Bouncy Castle's Scrypt implementation rather than the standalone library.
Amazingly, on a Pixel 2 this implementation is a bit quicker than Will Glozer/Colin Percival's native code.
2019-05-04 15:28:41 +02:00
Andreas Schildbach
7d973c8487 DeterministicKeyChain: Add getter for rootKey. 2019-05-03 23:14:39 +02:00