mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-20 02:09:29 +01:00
Fix a few max coins checks.
This is largely esoteric, but was brought up by https://github.com/schildbach/bitcoin-wallet/issues/299.
This commit is contained in:
parent
af769fe708
commit
8a41fd471f
@ -102,7 +102,7 @@ public class TransactionOutput extends ChildMessage {
|
||||
// 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.
|
||||
checkArgument(value.signum() >= 0 || value.equals(Coin.NEGATIVE_SATOSHI), "Negative values not allowed");
|
||||
checkArgument(value.compareTo(NetworkParameters.MAX_MONEY) < 0, "Values larger than MAX_MONEY not allowed");
|
||||
checkArgument(value.compareTo(NetworkParameters.MAX_MONEY) <= 0, "Values larger than MAX_MONEY not allowed");
|
||||
this.value = value.value;
|
||||
this.scriptBytes = scriptBytes;
|
||||
setParent(parent);
|
||||
|
@ -272,8 +272,8 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
|
||||
ClientState.StoredClientPaymentChannels.Builder builder = ClientState.StoredClientPaymentChannels.newBuilder();
|
||||
for (StoredClientChannel channel : mapChannels.values()) {
|
||||
// First a few asserts to make sure things won't break
|
||||
checkState(channel.valueToMe.signum() >= 0 && channel.valueToMe.compareTo(NetworkParameters.MAX_MONEY) < 0);
|
||||
checkState(channel.refundFees.signum() >= 0 && channel.refundFees.compareTo(NetworkParameters.MAX_MONEY) < 0);
|
||||
checkState(channel.valueToMe.signum() >= 0 && channel.valueToMe.compareTo(NetworkParameters.MAX_MONEY) <= 0);
|
||||
checkState(channel.refundFees.signum() >= 0 && channel.refundFees.compareTo(NetworkParameters.MAX_MONEY) <= 0);
|
||||
checkNotNull(channel.myKey.getPubKey());
|
||||
checkState(channel.refund.getConfidence().getSource() == TransactionConfidence.Source.SELF);
|
||||
final ClientState.StoredClientPaymentChannel.Builder value = ClientState.StoredClientPaymentChannel.newBuilder()
|
||||
|
@ -217,7 +217,7 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
|
||||
for (StoredServerChannel channel : mapChannels.values()) {
|
||||
// First a few asserts to make sure things won't break
|
||||
// TODO: Pull MAX_MONEY from network parameters
|
||||
checkState(channel.bestValueToMe.signum() >= 0 && channel.bestValueToMe.compareTo(NetworkParameters.MAX_MONEY) < 0);
|
||||
checkState(channel.bestValueToMe.signum() >= 0 && channel.bestValueToMe.compareTo(NetworkParameters.MAX_MONEY) <= 0);
|
||||
checkState(channel.refundTransactionUnlockTimeSecs > 0);
|
||||
checkNotNull(channel.myKey.getPrivKeyBytes());
|
||||
ServerState.StoredServerPaymentChannel.Builder channelBuilder = ServerState.StoredServerPaymentChannel.newBuilder()
|
||||
|
Loading…
Reference in New Issue
Block a user