4 - User B signs the transaction

The received signature requests from either subscribing to Websocket or subscribing to real-time notification can be signed through the following process.

Assuming the user subscribed to the real-time notification, they can include the decoding and signing process inside the callback function ofmultisig.wss.onReceiveSignRequest() as follows:


const signRequestCallback:SignatureRequestCallback =  async (message: SignatureRequest) => {
  
  const data: IDecodeTransaction = {
         signatureRequest:message,
         username: 'user-b'
      };
  const decodedTx:ITransaction = await multisig.utils.decodeTransaction(data);
  
  if(decodedTx){
    const sign: ISignTransaction = {
      decodedTransaction: decodedTx.transaction,
      signerId: decodedTx.signer.id,
      signatureRequestId: decodedTx.signatureRequestId,
      username,
      method: decodedTx.method,
    };
  
    const signatures: string[] = await multisig.wss.signTransaction(sign);
  }
};

await multisig.wss.onReceiveSignRequest(signRequestCallback);

The multisig.wss.signTransaction()returns an array of signatures. When this array contains one or more signatures, it means the transaction is ready for broadcasting otherwise not when it is empty.

ISignTransaction object

Last updated