org.web3j.utils.Numeric.toBigInt()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.web3j.utils.Numeric.toBigInt()方法的一些代码示例,展示了Numeric.toBigInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Numeric.toBigInt()方法的具体详情如下:
包路径:org.web3j.utils.Numeric
类名称:Numeric
方法名:toBigInt

Numeric.toBigInt介绍

暂无

代码示例

代码示例来源:origin: web3j/web3j

public static BigInteger toBigInt(byte[] value, int offset, int length) {
  return toBigInt((Arrays.copyOfRange(value, offset, offset + length)));
}

代码示例来源:origin: web3j/web3j

public static ECKeyPair deserialize(byte[] input) {
    if (input.length != PRIVATE_KEY_SIZE + PUBLIC_KEY_SIZE) {
      throw new RuntimeException("Invalid input key size");
    }

    BigInteger privateKey = Numeric.toBigInt(input, 0, PRIVATE_KEY_SIZE);
    BigInteger publicKey = Numeric.toBigInt(input, PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE);

    return new ECKeyPair(privateKey, publicKey);
  }
}

代码示例来源:origin: web3j/web3j

public void setV(Object v) {
  if (v instanceof String) {
    this.v = Numeric.toBigInt((String) v).longValueExact();
  } else if (v instanceof Integer) {
    this.v = ((Integer) v).longValue();
  } else {
    this.v = (Long) v;
  }
}

代码示例来源:origin: web3j/web3j

static Bool decodeBool(String rawInput, int offset) {
  String input = rawInput.substring(offset, offset + MAX_BYTE_LENGTH_FOR_HEX_STRING);
  BigInteger numericValue = Numeric.toBigInt(input);
  boolean value = numericValue.equals(BigInteger.ONE);
  return new Bool(value);
}

代码示例来源:origin: web3j/web3j

public static Bip32ECKeyPair create(byte[] privateKey, byte[] chainCode) {
  return create(Numeric.toBigInt(privateKey), chainCode);
}

代码示例来源:origin: web3j/web3j

@Test
public void testShhPost() throws Exception {
  //CHECKSTYLE:OFF
  web3j.shhPost(new ShhPost(
      "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1",
      "0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1",
      Arrays.asList("0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"),
      "0x7b2274797065223a226d6",
      Numeric.toBigInt("0x64"),
      Numeric.toBigInt("0x64"))).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_post\",\"params\":[{\"from\":\"0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1\",\"to\":\"0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1\",\"topics\":[\"0x776869737065722d636861742d636c69656e74\",\"0x4d5a695276454c39425154466b61693532\"],\"payload\":\"0x7b2274797065223a226d6\",\"priority\":\"0x64\",\"ttl\":\"0x64\"}],\"id\":1}");
  //CHECKSTYLE:ON
}

代码示例来源:origin: web3j/web3j

private void assertCorrectEntropy(String expected, String mnemonic, int size) {
    Assert.assertEquals(expected, Numeric.toHexStringNoPrefixZeroPadded(
        Numeric.toBigInt(MnemonicUtils.generateEntropy(mnemonic)), size));
  }
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthUninstallFilter() throws Exception {
  web3j.ethUninstallFilter(Numeric.toBigInt("0xb")).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_uninstallFilter\","
      + "\"params\":[\"0x0b\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetFilterChanges() throws Exception {
  web3j.ethGetFilterChanges(Numeric.toBigInt("0x16")).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getFilterChanges\","
      + "\"params\":[\"0x16\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetFilterLogs() throws Exception {
  web3j.ethGetFilterLogs(Numeric.toBigInt("0x16")).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getFilterLogs\","
      + "\"params\":[\"0x16\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testShhGetFilterChanges() throws Exception {
  web3j.shhGetFilterChanges(Numeric.toBigInt("0x7")).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_getFilterChanges\","
      + "\"params\":[\"0x07\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testShhUninstallFilter() throws Exception {
  web3j.shhUninstallFilter(Numeric.toBigInt("0x7")).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_uninstallFilter\","
      + "\"params\":[\"0x07\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
  public void testShhGetMessages() throws Exception {
    web3j.shhGetMessages(Numeric.toBigInt("0x7")).send();

    verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_getMessages\","
        + "\"params\":[\"0x07\"],\"id\":1}");
  }
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetCode() throws Exception {
  web3j.ethGetCode("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      DefaultBlockParameter.valueOf(Numeric.toBigInt("0x2"))).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\","
      + "\"params\":[\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\",\"0x2\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetTransactionByBlockNumberAndIndex() throws Exception {
  web3j.ethGetTransactionByBlockNumberAndIndex(
      DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionByBlockNumberAndIndex\","
      + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetBlockTransactionCountByNumber() throws Exception {
  web3j.ethGetBlockTransactionCountByNumber(
      DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockTransactionCountByNumber\","
      + "\"params\":[\"0xe8\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetUncleCountByBlockNumber() throws Exception {
  web3j.ethGetUncleCountByBlockNumber(
      DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleCountByBlockNumber\","
      + "\"params\":[\"0xe8\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetBlockByNumber() throws Exception {
  web3j.ethGetBlockByNumber(
      DefaultBlockParameter.valueOf(Numeric.toBigInt("0x1b4")), true).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\","
      + "\"params\":[\"0x1b4\",true],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetUncleByBlockNumberAndIndex() throws Exception {
  web3j.ethGetUncleByBlockNumberAndIndex(
      DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send();
  verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleByBlockNumberAndIndex\","
      + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}");
}

代码示例来源:origin: web3j/web3j

@Test
public void testEthGetLogsWithNumericBlockRange() throws Exception {
  web3j.ethGetLogs(new EthFilter(
      DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8")),
      DefaultBlockParameter.valueOf("latest"), ""))
      .send();
  verifyResult(
      "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getLogs\","
          + "\"params\":[{\"topics\":[],\"fromBlock\":\"0xe8\","
          + "\"toBlock\":\"latest\",\"address\":[\"\"]}],\"id\":1}");
}

相关文章