signMessage method

Future<String> signMessage({
  1. required String walletId,
  2. required String message,
  3. String? protocol,
  4. String? addressType,
  5. Map<String, dynamic>? approvalQuorum,
})

Signs a message using the specified Bitcoin wallet.

walletId is the unique identifier of the wallet to use for signing. message is the message string to sign. protocol is an optional signing protocol (ecdsa or bip322-simple). addressType is an optional address type (payment or ordinals).

Returns a Future that completes with the signature as a string.

Implementation

Future<String> signMessage({
  required String walletId,
  required String message,
  String? protocol,
  String? addressType,
  Map<String, dynamic>? approvalQuorum,
}) {
  final Map<String, dynamic> args = {
    'message': message,
    'walletId': walletId,
  };
  if (protocol != null) args['protocol'] = protocol;
  if (addressType != null) args['addressType'] = addressType;
  if (approvalQuorum != null) args['approvalQuorum'] = approvalQuorum;

  return requestChannel.request<String>(
    'bitcoin_signMessage',
    args: [args],
    builder: (data) => data['signature'] ?? data.toString(),
  );
}