org.bitcoinj.core.Utils.encodeMPI()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(153)

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

Utils.encodeMPI介绍

[英]MPI encoded numbers are produced by the OpenSSL BN_bn2mpi function. They consist of a 4 byte big endian length field, followed by the stated number of bytes representing the number in big endian format (with a sign bit).
[中]MPI编码的数字由OpenSSL BN_bn2mpi函数生成。它们由一个4字节的big-endian长度字段组成,后跟以big-endian格式表示数字的指定字节数(带符号位)。

代码示例

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.ONE.negate(), false)));
  break;
case OP_1:
case OP_15:
case OP_16:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(decodeFromOpN(opcode)), false)));
  break;
case OP_NOP:
  break;
case OP_DEPTH:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(stack.size()), false)));
  break;
case OP_DROP:
  if (stack.size() < 1)
    throw new ScriptException("Attempted OP_SIZE on an empty stack");
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(stack.getLast().length), false)));
  break;
case OP_INVERT:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPnum, false)));
  break;
case OP_2MUL:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPresult, false)));
  break;
case OP_MUL:

代码示例来源:origin: fr.acinq/bitcoinj-core

stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.ONE.negate(), false)));
  break;
case OP_1:
case OP_15:
case OP_16:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(decodeFromOpN(opcode)), false)));
  break;
case OP_NOP:
  break;
case OP_DEPTH:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(stack.size()), false)));
  break;
case OP_DROP:
  if (stack.size() < 1)
    throw new ScriptException(ScriptError.SCRIPT_ERR_INVALID_STACK_OPERATION, "Attempted OP_SIZE on an empty stack");
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(stack.getLast().length), false)));
  break;
case OP_EQUAL:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPnum, false)));
  break;
case OP_ADD:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPresult, false)));
  break;
case OP_NUMEQUALVERIFY:

代码示例来源:origin: greenaddress/GreenBits

out.write(Script.encodeToOpN((int)val));
  else
    Script.writeBytes(out, Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(val), false)));
} else if (w.matches("^0x[0-9a-fA-F]*$")) {

代码示例来源:origin: HashEngineering/dashj

stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.ONE.negate(), false)));
  break;
case OP_1:
case OP_15:
case OP_16:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(decodeFromOpN(opcode)), false)));
  break;
case OP_NOP:
  break;
case OP_DEPTH:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(stack.size()), false)));
  break;
case OP_DROP:
  if (stack.size() < 1)
    throw new ScriptException("Attempted OP_SIZE on an empty stack");
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(stack.getLast().length), false)));
  break;
case OP_INVERT:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPnum, false)));
  break;
case OP_2MUL:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPresult, false)));
  break;
case OP_MUL:

代码示例来源:origin: greenaddress/GreenBits

stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.ONE.negate(), false)));
  break;
case OP_1:
case OP_15:
case OP_16:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(decodeFromOpN(opcode)), false)));
  break;
case OP_NOP:
  break;
case OP_DEPTH:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(stack.size()), false)));
  break;
case OP_DROP:
  if (stack.size() < 1)
    throw new ScriptException("Attempted OP_SIZE on an empty stack");
  stack.add(Utils.reverseBytes(Utils.encodeMPI(BigInteger.valueOf(stack.getLast().length), false)));
  break;
case OP_INVERT:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPnum, false)));
  break;
case OP_2MUL:
  stack.add(Utils.reverseBytes(Utils.encodeMPI(numericOPresult, false)));
  break;
case OP_MUL:

代码示例来源:origin: HashEngineering/dashj

public static Script createCLTVPaymentChannelOutput(BigInteger time, ECKey from, ECKey to) {
  byte[] timeBytes = Utils.reverseBytes(Utils.encodeMPI(time, false));
  if (timeBytes.length > 5) {
    throw new RuntimeException("Time too large to encode as 5-byte int");
  }
  return new ScriptBuilder().op(OP_IF)
      .data(to.getPubKey()).op(OP_CHECKSIGVERIFY)
      .op(OP_ELSE)
      .data(timeBytes).op(OP_CHECKLOCKTIMEVERIFY).op(OP_DROP)
      .op(OP_ENDIF)
      .data(from.getPubKey()).op(OP_CHECKSIG).build();
}

代码示例来源:origin: fr.acinq/bitcoinj-core

public static Script createCLTVPaymentChannelOutput(BigInteger time, ECKey from, ECKey to) {
  byte[] timeBytes = Utils.reverseBytes(Utils.encodeMPI(time, false));
  if (timeBytes.length > 5) {
    throw new RuntimeException("Time too large to encode as 5-byte int");
  }
  return new ScriptBuilder().op(OP_IF)
      .data(to.getPubKey()).op(OP_CHECKSIGVERIFY)
      .op(OP_ELSE)
      .data(timeBytes).op(OP_CHECKLOCKTIMEVERIFY).op(OP_DROP)
      .op(OP_ENDIF)
      .data(from.getPubKey()).op(OP_CHECKSIG).build();
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

public static Script createCLTVPaymentChannelOutput(BigInteger time, ECKey from, ECKey to) {
  byte[] timeBytes = Utils.reverseBytes(Utils.encodeMPI(time, false));
  if (timeBytes.length > 5) {
    throw new RuntimeException("Time too large to encode as 5-byte int");
  }
  return new ScriptBuilder().op(OP_IF)
      .data(to.getPubKey()).op(OP_CHECKSIGVERIFY)
      .op(OP_ELSE)
      .data(timeBytes).op(OP_CHECKLOCKTIMEVERIFY).op(OP_DROP)
      .op(OP_ENDIF)
      .data(from.getPubKey()).op(OP_CHECKSIG).build();
}

代码示例来源:origin: greenaddress/GreenBits

public static Script createCLTVPaymentChannelOutput(BigInteger time, ECKey from, ECKey to) {
  byte[] timeBytes = Utils.reverseBytes(Utils.encodeMPI(time, false));
  if (timeBytes.length > 5) {
    throw new RuntimeException("Time too large to encode as 5-byte int");
  }
  return new ScriptBuilder().op(OP_IF)
      .data(to.getPubKey()).op(OP_CHECKSIGVERIFY)
      .op(OP_ELSE)
      .data(timeBytes).op(OP_CHECKLOCKTIMEVERIFY).op(OP_DROP)
      .op(OP_ENDIF)
      .data(from.getPubKey()).op(OP_CHECKSIG).build();
}

相关文章