Andreas Schildbach
ba72884832
Transaction: add back a byte[]
-based constructor as deprecated
2023-03-26 18:53:06 +02:00
Sean Gilligan
c05fefe8f8
MarriedKeyChain: simplify Builder.followingKeys()
...
* Add `followingKey()` method that takes a single key
* Deprecate unused `followingKeys(DeterministicKey, DeterministicKey...)`
* Replace usage of Guava's `Lists.asList()`
2023-03-26 18:49:32 +02:00
Sean Gilligan
6e1fc2cda9
WalletTool: rename tx
from t
in send()
2023-03-26 18:15:54 +02:00
Sean Gilligan
17f9b1dcfe
WalletTool: don't unnecessarily reinitialize tx variable t
in send()
2023-03-26 18:13:43 +02:00
Sean Gilligan
f58d07a623
ForwardingService: start()
returns receiving address
2023-03-26 18:10:09 +02:00
Sean Gilligan
3e1855b201
SendRequest: make field tx
immutable
2023-03-26 18:03:56 +02:00
Andreas Schildbach
4bdb8d7836
CheckpointManager: fix wrong unit of time
...
This mistake was introduced in commit 838b12c046
.
The original line before the `java.time` migration was:
`60 * 60 * 24 * 7; // one week in seconds`
2023-03-26 17:58:10 +02:00
Sean Gilligan
795da8f54b
Wallet: replace Guava newArrayList()
with singletonList()
2023-03-26 11:16:09 +02:00
Sean Gilligan
b7cf58ba6d
GuiUtils: replace Guava Throwables.getRootCause()
with private helper method
...
Private helper walks up the chain and avoids loops.
2023-03-26 01:50:02 +01:00
Sean Gilligan
66d96ab29d
WalletPasswordController: remove use of Guava Longs
...
Use ByteBuffer in private methods for long to byte[] conversion.
2023-03-26 01:47:03 +01:00
Sean Gilligan
8566819ff2
SendMoneyController: use CompletableFuture
not Guava
...
This is the last remaining use of Guava futures in
WalletTemplate.
2023-03-26 01:35:34 +01:00
Andreas Schildbach
7302a24962
.gitlab-ci.yml: create job artifacts
2023-03-26 00:28:11 +01:00
Andreas Schildbach
1753bc4ea7
.gitlab-ci.yml: print build environment at end of log
2023-03-25 21:03:43 +01:00
Andreas Schildbach
26e5500ae8
.gitlab-ci.yml: append JDK to job names
2023-03-25 21:01:00 +01:00
Andreas Schildbach
b585f9f08e
KeyChainGroupTest: reduce false positive rate for the bloom filters
...
This will hopefully reduce spurious test failures.
2023-03-25 13:29:20 +01:00
Andreas Schildbach
3bbbf40fa4
Message: add back deprecated method unsafeBitcoinSerialize()
2023-03-25 13:19:59 +01:00
Andreas Schildbach
c581dfb791
ByteUtils: rework JavaDoc of all writeInt*()
helpers
2023-03-24 19:35:52 +01:00
Andreas Schildbach
47a5d73035
ByteUtils: rename all writeUInt*()
helpers to writeInt*()
...
This creates overloads in some cases.
2023-03-24 19:34:06 +01:00
Sean Gilligan
f3c4b5fcf4
BloomFilter: use signed integer for the nonce (nTweak)
...
It's arbitrary data and we're not supposed to do math on it, so it's
safe to use a signed Java `int`.
Also use `new Random().nextInt()` to generate the nonce. We were
previously generating a random double, multiplying by `Long.MAX_VALUE`
and then truncating the low 32-bits of the long. Using `.nextInt()`
might actually generate MORE randomness since there will be no truncation.
2023-03-24 18:34:09 +01:00
Andreas Schildbach
b39ad1904d
Message: remove check against max message size in checkReadLength()
...
Checking against the remaining bytes in the payload should be enough.
The payload can't be longer than max message size.
2023-03-24 16:15:21 +01:00
Andreas Schildbach
9b3b11fd0f
Message: allow parse()
to throw BufferUnderflowException
...
The exception is now handled by the one caller to `parse()`, rather than
by various helpers.
2023-03-24 16:08:17 +01:00
Sean Gilligan
08e8c0c022
BloomFilterTest: use hex representation for constant
...
This avoids the `L` and also shows more clearly the
bit-pattern being used.
2023-03-24 15:44:34 +01:00
Andreas Schildbach
48f4d143f3
FeeFilterMessage: disallow negative fee rate
...
Fee rates are signed "int64_t", according to BIP-133. The spec doesn't
mention, but it goes without saying that negative fee rates make no
sense.
2023-03-24 15:32:54 +01:00
Andreas Schildbach
31d98af8f6
TransactionOutput: disallow negative values
...
Negative values obviously make no sense, except for `-1` which is
used as a sentinel value when calculating `SIGHASH_SINGLE` signatures,
so unfortunately we have to allow that here.
2023-03-24 15:30:02 +01:00
Andreas Schildbach
5bb1e123b6
VersionMessage: serialize negative time
values
...
Surprisingly, version messages serialize time as a `int64_t` (signed 64-bit integer).
2023-03-24 15:26:10 +01:00
Andreas Schildbach
7a0939f7e4
Ping: require a nonce value
...
Pings without nonce are not protocol compliant since version 60001.
Our minimum version is at 70000.
2023-03-24 13:16:34 +01:00
Sean Gilligan
42eb791d39
SeedPeers: use ByteBuffer
directly for address conversion
...
IPv4 addresses in `int` form don't care about signedness, and we
won't do math on them.
2023-03-24 11:31:26 +01:00
Andreas Schildbach
94bdbc29a0
UTXO, TransactionOutputChanges: remove unused serialization code
...
This was left over when we removed `UTXOsMessage` in d07e75e2a8
.
2023-03-24 10:49:32 +01:00
Andreas Schildbach
dadeb71cb3
VersionMessage: use skipBytes()
to skip over a value we don't ware about
2023-03-23 18:47:39 +01:00
Andreas Schildbach
ed57fa08ed
Message: make serializer
field immutable
...
This requires two new pass-through constructors, but in return we
get rid of the setter.
2023-03-23 13:34:31 +01:00
Andreas Schildbach
b8f77abe62
SeedPeers: fix conversion of int representation of IPv4 addresses to InetAddress
...
Usage of `writeUint32LE()` is wrong on two counts:
* `InetAddress.getByAddress()` expects big-endian values, and the method
above encodes as little-endian.
* Java int is signed, even if the Java hex literal appears unsigned. The
above method expects unsigned values.
So we add the previously missing `writeInt32BE()` to ByteUtils and use it.
2023-03-23 00:28:37 +01:00
Andreas Schildbach
72370d0ff6
Sha256Hash: add reading from and writing to ByteBuffer
...
Includes a test.
2023-03-22 22:19:54 +01:00
Andreas Schildbach
30dec4ff7c
Message: replace readBytes(1)[0]
with readByte()
2023-03-22 21:39:05 +01:00
Andreas Schildbach
89198853d1
TransactionInput: check sequence
bounds
...
It turns out a test is supplying an invalid fake value.
This is now fixed.
2023-03-22 20:32:31 +01:00
Andreas Schildbach
014939410e
TransactionOutPoint: check index
bounds
...
It turns out some tests are supplying an invalid fake value for
coinbase transaction. This is now fixed.
2023-03-22 20:23:56 +01:00
Andreas Schildbach
c577303aed
TransactionTest: don't use a custom protocol version in a test
...
The current default will do fine.
2023-03-22 20:06:41 +01:00
Andreas Schildbach
a7bd460865
Message: make params
field immutable
2023-03-22 18:46:11 +01:00
Andreas Schildbach
be12c389f3
Message: parse the original ByteBuffer
, rather than a copy of it
...
This has the advantage of using the read position contained in
`ByteBuffer`, so we remove our `offset` and `cursor` fields.
2023-03-22 15:04:05 +01:00
Andreas Schildbach
32837798c1
Message: remove length
and optimalEncodingMessageSize
fields
...
This does away with a lot of updating the fields while parsing and
mutating the data.
`getMessageSize()` now returns the length of the data as
serialized by `bitcoinSerializeToStream()`, which can be different
from the length of an original payload.
The default implementation of `getMessageSize()` is not performant
enough for all usecases, to it is overridden in strategic subclasses
to calculate the size in a much more efficient way.
2023-03-22 14:31:26 +01:00
Andreas Schildbach
7fba2d8c6b
Message: fold unsafeBitcoinSerialize()
into bitcoinSerialize()
2023-03-22 02:21:21 +01:00
Andreas Schildbach
e882322505
Message: fold bitcoinSerialize()
into bitcoinSerializeToStream()
2023-03-22 02:06:35 +01:00
Andreas Schildbach
01bf08159d
FilteredBlock: simplify parse()
a bit by using readBytes()
2023-03-21 23:35:57 +01:00
Sean Gilligan
52b2f63d70
VarIntTest: use JUnitParamsRunner
...
* Parameterize the existing tests
* Test more functionality
* Test more data variations
2023-03-21 23:15:34 +01:00
Andreas Schildbach
58500cfb46
VarInt: add reading from and writing into ByteBuffer
2023-03-21 23:04:35 +01:00
Andreas Schildbach
0da35c6a0c
VarInt: migrate native constructors to static constructors
...
The old native constructors have been deprecated.
2023-03-21 23:02:41 +01:00
Andreas Schildbach
abdba75019
Block: simplify parse()
-parseTransactions()
interaction
2023-03-21 22:54:44 +01:00
Andreas Schildbach
9d9cadd59c
Message: in constructors wrap payload bytes and offset into a ByteBuffer
...
This reduces arguments of constructors and does away with
a couple of constructor variants.
2023-03-21 17:55:32 +01:00
Andreas Schildbach
7303043f37
ByteUtils: rename read helpers that read from streams
2023-03-21 17:46:26 +01:00
Andreas Schildbach
d89718aaf6
ByteUtils: add reading from and writing to ByteBuffer
...
This gets rid of a lot of manual bit shuffling.
2023-03-21 17:32:05 +01:00
Andreas Schildbach
c372a87ea4
ByteUtils: properly document all read and write helpers
2023-03-21 17:18:51 +01:00