toRpcSig method
Convert signature parameters into the format of eth_sign RPC method.
Implementation
String toRpcSig({int chainId = -1}) {
var recovery = _calculateSigRecovery(v, chainId: chainId);
if (!_isValidSigRecovery(recovery)) throw ArgumentError('Invalid signature v value');
// geth (and the RPC eth_sign method) uses the 65 byte format used by Bitcoin
var bytesBuffer = BytesBuffer();
bytesBuffer.add(setLengthLeft(r, 32));
bytesBuffer.add(setLengthLeft(s, 32));
bytesBuffer.add(toBuffer(BigInt.from(v)));
return bufferToHex(bytesBuffer.toBytes());
}