Basic- Creating Multi-Sig Wallet
In this lesson, we will show you how to create multi-sig wallet.
You can generate a new multi-sig wallet using quras-js module. Then let's see about this step by step.
Create Multi-Sig Wallet Template
You can generate the multi-sig wallet template with your pubkey to create a new multi-sig wallet.
var tx = Quras.tx.Transaction.createRegisterMultiSignTx('022d597ef40181c3f075d2b8612611785aa275485e7ede57c3d07664f254f99450'); // set your pubkey.
Relay Multi-Sig Wallet Tx Data
Multi-Sig wallet contains more than one wallet and they have to send the multi-sig wallet tx data to each other.
Quras.tx.getMultiSignWalletTxRawData(tx) // Get raw data of multi-sig wallet tx.
var tx = Quras.tx.Transaction.getMultiSignWalletTx(rawdata); // Get Multi-Sig wallet tx from raw data.
Join Multi-Sig Wallet
After you receive the multi-sig wallet data, you can join multi-sig wallet with your pubkey to participate multi-sig transactions.
tx = Quras.tx.Transaction.joinMultiSignWallet(tx, '035575f88c6f0e41fc7cc657b040f34902337d13dbc1b18dd2c3eac3f2e576d6b3'); // set your pubkey.
Get Multi-Sig Wallet Address
You can get multi-sig wallet address to be created.
var scripthash = Quras.tx.Transaction.getMultiSignScriptHash(tx);
var addr = Quras.wallet.getAddressFromScriptHash(scripthash);
Broadcast Multi-Sig Wallet Tx
After everybody joint multi-sig wallet tx, you have to send the tx to RPC server.
tx.sign('7946ec98ebfa9e064101584b91db3275f485391d6eec345650bcceb861874c0a'); // Sign the transaction using private key           
const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
rpcServer.sendRawTransaction(tx.serialize()) // Send the transaction to RPC Server.
.then((data) => {
    console.log(data);
})
.catch ((error) => {
    console.log("error");
});