psbtToGlobalMap static method

Map<String, String> psbtToGlobalMap(
  1. Uint8List psbtBytes,
  2. int offset
)

Implementation

static Map<String, String> psbtToGlobalMap(Uint8List psbtBytes, int offset) {
  Map<String, String> globalMap = {};
  while (true) {
    int keyLen = Varints.read(psbtBytes, offset);
    offset += _getOffset(psbtBytes[offset]);
    if (keyLen == 0) {
      break;
    }
    Uint8List key = psbtBytes.sublist(offset, offset + keyLen);
    offset += keyLen;
    int valueLen = Varints.read(psbtBytes, offset);
    offset += _getOffset(psbtBytes[offset]);
    Uint8List value = psbtBytes.sublist(offset, offset + valueLen);
    offset += valueLen;
    globalMap[Converter.bytesToHex(key)] = Converter.bytesToHex(value);
  }
  return globalMap;
}