3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 10:45:51 +00:00

1980 Commits

Author SHA1 Message Date
Ross Nicoll
92bd6d0af1 Add transaction tests for OP_CHECKLOCKTIMEVERIFY 2015-11-23 17:23:43 +01:00
Andreas Schildbach
f9097ab408 Block: Print hash in toString(). 2015-11-23 16:54:43 +01:00
Andreas Schildbach
63a5e3b410 Block: Add convenience methods for BIP conformance (BIP34, BIP66, BIP65, BIP101). Also list BIPs in Block.toString(). 2015-11-23 16:54:43 +01:00
Andreas Schildbach
fe736d2554 Fold CoinbaseBlockTest into BlockTest. 2015-11-23 16:39:05 +01:00
Ross Nicoll
723df867ff Genericise script number encoder
This replaces the limited script number encoder previously used for block
height with a version that matches the exact format generated by Bitcoin
Core (which can include an additional byte for sign in some cases).

With thanks to Kalpesh Parmar for pointing out that some blocks on the
testnet have coinbase transactions with height encoded in 2 bytes.
2015-11-20 18:58:10 +00:00
Andreas Schildbach
d08bda2ae4 CoinbaseBlockTest: Convert some file loading code to use Guava. 2015-11-19 22:40:58 +01:00
Ross Nicoll
ad42302355 Add hooks to override protocol version numbers 2015-10-31 16:18:17 +01:00
Ross Nicoll
377d226ef1 Enforce the LOW_S script validation flag 2015-10-31 16:10:48 +01:00
Ross Nicoll
344c4c3baa Enforce v4 block switchover
This enforces the switch over to block v4 once a supermajority is met, as
per BIP65.
2015-10-28 10:34:57 +01:00
langerhans
a6d3bbbb77 Remove redundant return statements 2015-10-24 19:44:34 +02:00
Andreas Schildbach
4a735008a5 Make peer discovery timeout configurable. Add milliseconds to error message if timeout kicks in. 2015-10-21 18:07:25 +02:00
Ross Nicoll
4a3d702397 Correct coinbase height script validation
Changes coinbase height validation to check for the bytes at the start of
the coinbase script, and ignore everything after them. The validation then
matches Bitcoin Core.

Also update error messages to more closely match latest Bitcoin Core.
2015-10-21 15:00:44 +02:00
ollekullberg
724cf7de36 Close increasePaymentFuture when receiving an ERROR from the server. 2015-10-21 14:56:18 +02:00
Ross Nicoll
829e147ec7 Add script verification flags for DER format
Add script verification flags for DER format encoding, low-S signatures
and strict encoding.
Pass script verification flags through to signature parser.
Convert block verification flags to a sub-enum of Block.
Remove DER signature format verification flag from block flags.
Add test transaction with a non-standard DER signature, with the verify
flag set/unset accordingly, to tx_invalid.json and tx_valid.json
2015-10-20 13:37:27 +02:00
Ross Nicoll
1c74aac27e Add support for block headers of variable length, when parsing headers messages. 2015-10-18 17:45:06 +01:00
Ross Nicoll
e136642807 Correct length of block header when hashing at an offset 2015-10-18 17:10:56 +02:00
Marc-André Tremblay
4379ca7b94 Fix how key depth is determined.
The way it was previously done before did not allow to properly derive keys which had their position concealed in the hierarchy.

Signed-off-by: Marc-André Tremblay <marcandre.tr@gmail.com>
2015-10-18 17:03:49 +02:00
Ross Nicoll
df56a23f09 Clean up MessageSerializer to simplify subclasses
By replacing MessageSerializer with an abstract class, methods which
should just call other methods in the same class are now fixed, and
subclasses only have to override a single abstract method instead of
multiple.
2015-10-18 16:37:49 +02:00
Ross Nicoll
4375f66d20 Replace magic numbers for header sizes with constants 2015-10-18 12:37:27 +02:00
Andreas Schildbach
a4c9ad6894 Make transactions with signatures with "high" S component violate the "canonical encoding" rule.
This makes those transactions non-standard and risky. By default, they will not be accepted into wallets unless confirmed by the block chain.
2015-10-15 10:42:26 +02:00
Andreas Schildbach
52b9623262 Wallet: Fix printing the same transaction twice when two pending transactions double spend each other are seen. 2015-10-14 15:56:25 +02:00
Mike Hearn
761834bc18 Allow some monkey-patching of Peer methods/Peer creation.
Fix a bug in the min version required feature.
2015-10-08 19:15:07 +02:00
Mike Hearn
0079c272ff PeerGroup: fix a bug that'd leave maxConnections == 0 if setRequiredServices was used without configuring any other discovery (a typical use case). 2015-10-08 16:10:48 +02:00
Mike Hearn
fabbb0a9ac Tweak HS integration again to avoid performance regression. 2015-10-08 15:56:44 +02:00
Mike Hearn
e104bfbb7e PeerAddress/HttpDiscovery: accept unresolved InetSocketAddresses to avoid super-slow reverse DNS lookups for HTTPSeed discovered peers. 2015-10-08 14:51:47 +02:00
Mike Hearn
3d322d5c98 Block/FakeTxBuilder: restore API compat 2015-10-08 14:51:11 +02:00
Mike Hearn
979d20996e PeerAddress: simplify dead code 2015-10-08 13:51:14 +02:00
Mike Hearn
f9c6ded2b8 GetUTXOSMessage: int -> long for flags constant (makes Kotlin interop smoother) 2015-10-08 13:45:34 +02:00
Glenn Marien
ce22d1a493 Fixed imported keys not being passed onto UTXOProvider 2015-10-05 18:00:49 +02:00
Mike Hearn
9ba1be762a Wallet: flip argument ordering in deprecated Wallet.addEventListener to restore compatibility with 0.13 2015-10-05 17:12:55 +02:00
Mike Hearn
0342feee86 PeerGroup: restore and deprecate some removed addEventListener methods 2015-10-05 17:03:20 +02:00
Mike Hearn
f5db4b92be Reverse the order of ListenerRegistration c'tor to restore compatibility with bcj 0.13 2015-10-05 17:01:02 +02:00
Mike Hearn
9bfce1bae0 Remove no longer used variable. 2015-09-30 17:21:39 +02:00
dexX7
be41d84fb9
Add more script edge condition tests
Original submission:
```
commit 1c54757f8678c9131ec55c128b8f1d5b6c73c2f9
Author: Dave Collins <davec@conformal.com>
Date:   Wed May 6 10:16:18 2015 -0500

    Add more script edge condition tests.

    This commit adds some tests to the script_valid.json and tx_invalid.json
    data which exercise more edge conditions that are not currently being
    tested.
```

Via:
https://github.com/bitcoin/bitcoin/pull/6112
2015-09-30 00:34:08 +02:00
dexX7
a3d378bae6
Ensure "OP_0" and "false" have the same represenstation on stack
During the script execution via `executeScript()` certain operations
add boolean values to the stack.

Boolean values, which are added to the stack as result, are represented
as follows in Bitcoin Core:

- `true`: as vector with one element: `[1]`
- `false`: as empty vector with zero elements: `[]`

See:

- 48efbdbe98/src/script/interpreter.cpp (L244)
- 48efbdbe98/src/script/interpreter.cpp (L246)

However, in BitcoinJ the representation of `false` differs in some
cases, where it is represented as Byte array with one element, which
is zero: `[0]`

See:

- `OP_EQUAL`: 5dcf643975/core/src/main/java/org/bitcoinj/script/Script.java (L1025)
- `OP_CHECKSIG`: 5dcf643975/core/src/main/java/org/bitcoinj/script/Script.java (L1304)
- `OP_CHECKMULTISIG`: 5dcf643975/core/src/main/java/org/bitcoinj/script/Script.java (L1381)

At minimum this has an impact on the behavior of `OP_EQUAL` and
`OP_EQUALVERIFY`, when comparing something with `OP_FALSE`/`OP_0`.

This commit attemps to fix the issue, to mirror the verification
behavior of Bitcoin Core, by adding empty Byte arrays to the stack,
instead of Byte arrays with `0`.
2015-09-30 00:30:29 +02:00
Mike Hearn
7014810cf6 Peer: Break out the onTransactionBroadcast event into a separate interface. 2015-09-18 21:10:53 +01:00
Mike Hearn
c2a67aaa59 Fix thread safety issue when creating multiple wallets in parallel. 2015-09-16 14:11:19 +01:00
Andreas Schildbach
f20cb1132d WalletProtobufSerializer: Rethrow IllegalArgumentException when loading wallets. 2015-09-05 19:23:18 +02:00
Matt Bogosian
66a851bd30 Fix #1078. Add ability to load Wallet without loading its transactions. Use new methods with wallet-tool reset (where transactions are deleted anyway) and with wallet-tool sync (if the --force option is provided). 2015-09-04 18:07:26 +02:00
cyberzac
7c8c2a4b02 Allowing settlement of unused channel 2015-09-04 16:13:49 +02:00
Mike Hearn
fc9ae41883 Restore some deprecated backwards compatibility glue for the event listener changes. 2015-09-02 20:40:22 +02:00
Mike Hearn
5e15c04305 AbstractBlockChain: remove useless final declarations from event listener registration methods added in recent commits 2015-09-02 20:10:38 +02:00
Mike Hearn
9470601ea5 Wallet: make balance futures work for all balance types 2015-09-02 20:10:38 +02:00
Mike Hearn
a73677e9fb DeterministicKey: throw a KeyCrypterException instead of an IllegalStateException if the derivation check fails (as this can happen when the password is wrong) 2015-09-02 20:10:38 +02:00
Mike Hearn
48b4df73a1 Coin: more aliases 2015-09-02 20:10:37 +02:00
Oscar Guindzberg
629e5d864d Rename getChangeAddress() to currentChangeAddress() 2015-09-01 17:39:46 -03:00
Mike Hearn
207ef37894 Coin: add plus/minus aliases for add/subtract. This activates Kotlin operator overloading support. 2015-08-31 15:46:01 +02:00
Mike Hearn
864f2529e8 Wallet: make getUnspents() public. 2015-08-31 15:12:02 +02:00
Mike Hearn
6b4123cd9f Comparison tool: take out the warning sleep 2015-08-27 15:21:50 +02:00
Ross Nicoll
d3d11df6d7 Add BIP 34 enforcement
This patch primarily enforces block height being present in the coinbase
transaction input, altough it introduces a number of other fixes and
changes to support this.

* VersionTally now returns the number of blocks at or above a version, rather than just at, to enable forward-compatible support (i.e. v3 blocks include all v2 block tests)
* Block version is now explicitely provided in most tests which generate blocks, in order to ensure correct tests are applied
* Block height is now used when generating coinbase transactions
* Added support for the chain parameters to determine which tests apply to a block, so altcoins can override the defaults if needed.
* Added initial checks ahead of full BIP 66 validation checks
2015-08-27 15:12:39 +02:00