Constructing Bitcoin Multisig Addresses

While many are familiar with Bitcoin multisig addresses, seems when you come to program them, they are very confusing.

In recent Bitcoin payment solution, built with Laravel we used multisig addresses, and discovered how confusing these can be.

We are working with our bitcoin node, starting with regtest and then testnet, followed by livenet.

Wallet Addresses

For a multisig address constructed from addresses that are in the wallet on the node, one can use the public address to be the public key using validateAddress.

Non Wallet Addresses

For a multisig address constructed using an address that is not in the wallet on the node, you need the public key for that address.

Now, getting that public key is not simple, as most bitcoin wallets do not support fetching it. The well known Electrum wallet does provide the public key easily.