I am trying to create a multisig wallet from two externally generated xpubs. The process I am taking is to create two multisig wallets with the two xpubs, add each others keys as shared keys and generating the multisigscript using keyrings. However, when I send testnet coins to the base58addr
that I generate in the end, I do not see it coming to either of my wallets. Could someone kindly help me figure out where I am doing wrong? This is my code:
const wallet1_accountKey = "tpubDCe8iQEHFMvcm9WZsYZEd8h9dNvoDidS3y9EVkDzZZr59NcNF2n8ecfZWQkttDp6PWujaCUcXrptSoTKUuYjXp8fMKsz3wJvYpnpxsMQUbD"
const wallet2_accountKey = "tpubDDQHqrK6Xj7A9tfW2zkiZiBPs475QJ8EQ5obViboBxgA1BG5Ai1BnPqBWKTVf6ecEi8XoKK9WQP7GK5jYgdjaoegqBH1EvhVCx2PLc3Zgru"
const type='multisig'
const options_wallet1 = {
...
};
const options_wallet2 = {
...
};
const result1 = await walletClient.createWallet('wallet1', options_wallet1);
const result2 = await walletClient.createWallet('wallet2', options_wallet2);
// ADDING SHARED KEYS
const wallet1 = walletClient.wallet('wallet1');
const wallet2 = walletClient.wallet('wallet2');
const wallet1_account = await wallet1.getAccount('default');
const result3 = await wallet2.addSharedKey('default', wallet1_account.accountKey);
const wallet2_account = await wallet6.getAccount('default');
const result4 = await wallet1.addSharedKey('default', wallet2_account.accountKey);
// GENERATING P2SH WITH KEYRINGS
const wallet1_address = await wallet1.createAddress('default');
const wallet2_address = await wallet2.createAddress('default');
const ring1 = KeyRing.fromJSON(wallet1_address);
const ring2 = KeyRing.fromJSON(wallet2_address);
const pubKeys = [ring1.publicKey, ring2.publicKey];
const multiSigScript = Script.fromMultisig(m, n, pubKeys);
const base58addr = multiSigScript.getAddress().toBase58('testnet');