signMessage

Request the signature of an arbitrary message with the first Bitcoin address (Native SegWit or Taproot) of an account

Method name

signMessage

Parameters

Example request

import { Verifier } from "bip322-js";

try {
  // Request signature
  const response = await window.LeatherProvider.request("signMessage", {
    message: "Hello world",
    paymentType: "p2tr",
    network: "testnet",
    account: 0
  });

  console.log("Response:", response);

  // Verify signature
  try {
    const isValid = Verifier.verifySignature(
      response.result.address,
      response.result.message,
      response.result.signature
    );

    console.log("Signature is valid: ", isValid);
  } catch (error) {
    console.log("Verification error:", error);
  }
} catch (error) {
  console.log("Request error:", error.error.code, error.error.message);
}

Example response

{
    "jsonrpc": "2.0",
    "id": "adc296e9-beb7-4685-a443-24c30d0d04dd",
    "result": {
        "signature": "AUDl4ZQJo585ldL0I9S+CjDpT7+5WB2Sspgh47Dsx0WX0iZSCLV+K6smOKJ1u4IUaN6grvNspaZ9GpqPOOHsTTVE",
        "address": "tb1pwfstsmedjfr84rzjsnsjly7x0utzlcfed0uqv26vmwsrvvzuf82qsad4uz",
        "message": "Hello world"
    }
}

Sandbox

Install the Leather extension then try out this method below:

Preview

Last updated