Commit graph

2424 commits

Author SHA1 Message Date
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
Andreas Schildbach
d94380caec KeyChainFactory: Remove unused key and firstSubKey parameters from all factory methods. 2019-05-03 23:02:37 +02:00
Andreas Schildbach
1a8e4c9978 HDKeyDerivation: Add convenience methods deriveChildKeyFromPrivate() and deriveChildKeyFromPublic().
Also add extensive testing.
2019-05-03 22:55:20 +02:00
Andreas Schildbach
701fc38c00 HDKeyDerivation: Make precondition message more clear in deriveChildKeyBytesFromPublic(). 2019-05-03 22:50:37 +02:00
Andreas Schildbach
6035608b02 Deprecate Transaction.MIN_NONDUST_OUTPUT and NetworkParameters.getMinNonDustOutput(). Remove DefaultRiskAnalysis.MIN_ANALYSIS_NONDUST_OUTPUT.
The dust threshold has always been dependent on the actual output script type. Even more so with the
SegWit discount. So use TransactionOutput.getMinNonDustValue() or .isDust().
2019-05-02 10:36:32 +02:00
Andreas Schildbach
40eff8cba2 UTXOsMessage: Clarify a comment. 2019-04-30 12:11:51 +02:00
Oscar Guindzberg
56358f8ab5 Script: Add links to new methods replacing deprecated methods. 2019-04-29 10:34:16 +02:00
Oscar Guindzberg
84a8446a2f TransactionConfidence: Fix typo in JavaDoc. 2019-04-29 10:31:12 +02:00
Andreas Schildbach
c168e67703 Wallet: Implement witness fee discount.
Fee is now specified in virtual (kilo)bytes. For non-segwit transactions a virtual byte is the same as a byte so the change is backward compatible.
2019-04-29 10:03:04 +02:00
Andreas Schildbach
2fc1b1131c Transaction: Move sizes to top in toString(), and print the weight too. 2019-04-29 09:31:56 +02:00
Andreas Schildbach
c97ecf6046 Transaction: Add methods for calculating transaction weight and virtual transaction size. 2019-04-28 19:16:50 +02:00
Andreas Schildbach
25f36872d5 TransactionOutput: Consider the witness discount in getMinNonDustValue(). 2019-04-28 15:22:53 +02:00
Andreas Schildbach
fb353d744e Fix unbalanced <p> tags in JavaDocs. 2019-04-28 13:48:37 +02:00
Matthew Leon
7f72faed3e Transaction: Simplify error checking in verify(). 2019-04-23 12:03:33 +02:00
Matthew Leon
6378d3829d LegacyAddress: Update outdated JavaDoc reference.
It suggests using a deprecated method.
2019-04-23 09:51:55 +02:00
Jakob Janecek
f2e59611f1 Block: Access transactions via getter rather than directly through the field. 2019-04-22 17:03:31 +02:00
Matthew Leon
b6c2b0946f TransactionOutput: Kill an unnecessary instance variable. 2019-04-18 16:49:03 +02:00
Oscar Guindzberg
26b30994b8 Wallet: Rename addScriptChangeEventListener() to addScriptsChangeEventListener() and removeScriptChangeEventListener() to removeScriptsChangeEventListener(), for the sake of naming consistency.
This renames related class fields too.
2019-04-17 18:51:33 +02:00
Matthew Leon
73ddffb38f Script: Ensure that non-canonical sigs result in script failure. 2019-04-17 16:17:02 +02:00
Oscar Guindzberg
98cff1d5b8 WalletAppKit: Remove redundant throws declaration. 2019-04-15 19:49:32 -03:00
Andreas Schildbach
d686d74903 Peer: Ignore incoming SendHeaders messages, because we don't announce new blocks. 2019-04-14 20:34:10 +02:00
Jakob Janecek
a00f751a56 Replace use of Utils.currentTimeMillis() with Utils.currentTimeSeconds() where appropriate. 2019-04-14 19:18:16 +02:00
Oscar Guindzberg
66289d6f39 WalletAppKit: Remove unnecessary call to KeyChainGroup.Builder.build(). 2019-04-13 02:18:38 +02:00
Oscar Guindzberg
0af0439b3f Wallet: Fix script type in deprecated findKeyFromPubHash(). 2019-04-11 18:36:14 +02:00
Sean Gilligan
783dd45c4b Wallet: Remove (or reduce visibility of) the deprecated constructors.
Replace usages in unit tests and examples with usage of the static createDeterministic() constructor.
2019-04-08 11:23:41 +02:00
Andreas Schildbach
1985c007b3 ECKey: Decrypted keys must always be 32 bytes long, otherwise likely the encryption key was wrong. 2019-04-06 10:32:05 +02:00