use of org.ethereum.rpc.exception.JsonRpcInvalidParamException in project rskj by rsksmart.
the class Web3ImplScoringTest method addBannedAddressWithInvalidMask.
@Test
public void addBannedAddressWithInvalidMask() throws UnknownHostException {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
try {
web3.sco_banAddress("192.168.56.1/a");
Assert.fail();
} catch (JsonRpcInvalidParamException ex) {
Assert.assertEquals("invalid banned address 192.168.56.1/a", ex.getMessage());
}
}
use of org.ethereum.rpc.exception.JsonRpcInvalidParamException in project rskj by rsksmart.
the class EthModuleWalletEnabled method sendTransaction.
@Override
public synchronized String sendTransaction(Web3.CallArguments args) {
Account account = this.getAccount(args.from);
String s = null;
try {
if (account == null) {
throw new JsonRpcInvalidParamException("From address private key could not be found in this node");
}
String toAddress = args.to != null ? Hex.toHexString(stringHexToByteArray(args.to)) : null;
BigInteger value = args.value != null ? TypeConverter.stringNumberAsBigInt(args.value) : BigInteger.ZERO;
BigInteger gasPrice = args.gasPrice != null ? TypeConverter.stringNumberAsBigInt(args.gasPrice) : BigInteger.ZERO;
BigInteger gasLimit = args.gas != null ? TypeConverter.stringNumberAsBigInt(args.gas) : BigInteger.valueOf(GasCost.TRANSACTION_DEFAULT);
if (args.data != null && args.data.startsWith("0x")) {
args.data = args.data.substring(2);
}
synchronized (transactionPool) {
BigInteger accountNonce = args.nonce != null ? TypeConverter.stringNumberAsBigInt(args.nonce) : transactionPool.getRepository().getNonce(account.getAddress());
Transaction tx = Transaction.create(config, toAddress, value, accountNonce, gasPrice, gasLimit, args.data);
tx.sign(account.getEcKey().getPrivKeyBytes());
eth.submitTransaction(tx.toImmutableTransaction());
s = tx.getHash().toJsonString();
}
return s;
} finally {
LOGGER.debug("eth_sendTransaction({}): {}", args, s);
}
}
use of org.ethereum.rpc.exception.JsonRpcInvalidParamException in project rskj by rsksmart.
the class Web3Impl method eth_getBlocksByNumber.
public BlockInformationResult[] eth_getBlocksByNumber(String number) {
long blockNumber;
try {
blockNumber = TypeConverter.stringNumberAsBigInt(number).longValue();
} catch (NumberFormatException | StringIndexOutOfBoundsException e) {
throw new JsonRpcInvalidParamException("invalid blocknumber " + number);
}
List<BlockInformationResult> result = new ArrayList<>();
List<BlockInformation> binfos = blockchain.getBlocksInformationByNumber(blockNumber);
for (BlockInformation binfo : binfos) {
result.add(getBlockInformationResult(binfo));
}
return result.toArray(new BlockInformationResult[result.size()]);
}
use of org.ethereum.rpc.exception.JsonRpcInvalidParamException in project rskj by rsksmart.
the class Web3Impl method evm_increaseTime.
@Override
public String evm_increaseTime(String seconds) {
try {
long nseconds = stringNumberAsBigInt(seconds).longValue();
String result = toJsonHex(minerServer.increaseTime(nseconds));
if (logger.isDebugEnabled()) {
logger.debug("evm_increaseTime({}): {}", nseconds, result);
}
return result;
} catch (NumberFormatException | StringIndexOutOfBoundsException e) {
throw new JsonRpcInvalidParamException("invalid number of seconds " + seconds, e);
}
}
use of org.ethereum.rpc.exception.JsonRpcInvalidParamException in project rskj by rsksmart.
the class Web3ImplScoringTest method removeBannedAddressWithInvalidMask.
@Test
public void removeBannedAddressWithInvalidMask() throws UnknownHostException {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
try {
web3.sco_unbanAddress("192.168.56.1/a");
Assert.fail();
} catch (JsonRpcInvalidParamException ex) {
Assert.assertEquals("invalid banned address 192.168.56.1/a", ex.getMessage());
}
}
Aggregations