Hive Multisig SDK
  • Welcome!
  • Quick Start
  • WebSocket flow
    • 1 - Users connect to the Websocket
    • 2 - User A requests a transaction
    • 3 - User B receives the signature request
    • 4 - User B signs the transaction
    • 5 - User B broadcasts the transaction
    • 6 - Users both receive a successful broadcast notification
  • API
  • Utils
    • Encode Transaction
    • Decode Transaction
  • Static helpers
    • Get/Reset HiveMultisig instance
    • Get Signers
    • Get Authorities
    • Validate Initiator
  • Demo
Powered by GitBook
On this page
  1. WebSocket flow

4 - User B signs the transaction

Previous3 - User B receives the signature requestNext5 - User B broadcasts the transaction

Last updated 1 year ago

The received signature requests from either or subscribing to can be signed through the following process.

Assuming the user subscribed to the, 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

Property
Description
Type

decodedTransaction

The decoded transaction obtained from multisig.utils.decodeTransaction()

dhive Transaction

signerId

A signer id assigned by the backend

number

signatureRequestId

The signature request id assigned by the backend.

number

username

username of the signer

string

method

The keyType used when initiating the transaction

KeychainKeyTypes enum

subscribing to Websocket
real-time notification
Start by decoding the transaction.
real-time notification