forInputSequence method

Uint8List forInputSequence()

Serializes the relative sequence as required in a transaction

Implementation

Uint8List forInputSequence() {
  if (seqType == TYPE_ABSOLUTE_TIMELOCK) {
    return Uint8List.fromList(ABSOLUTE_TIMELOCK_SEQUENCE);
  }

  if (seqType == TYPE_REPLACE_BY_FEE) {
    return Uint8List.fromList(REPLACE_BY_FEE_SEQUENCE);
  }
  if (seqType == TYPE_RELATIVE_TIMELOCK) {
    int seq = 0;
    if (!isTypeBlock) {
      seq |= 1 << 22;
    }
    seq |= value;
    return Uint8List.fromList([
      seq & 0xFF,
      (seq >> 8) & 0xFF,
      (seq >> 16) & 0xFF,
      (seq >> 24) & 0xFF,
    ]);
  }

  throw ArgumentError("Invalid seqType");
}