func (w *Wallet) MakeMultiSigScript(addrs []bchutil.Address, nRequired int) ([]byte, error) {
	pubKeys := make([]*bchutil.AddressPubKey, len(addrs))
	var dbtx walletdb.ReadTx
	var addrmgrNs walletdb.ReadBucket
	defer func() {
		if dbtx != nil {
			dbtx.Rollback()
		}
	}()
	for i, addr := range addrs {
		switch addr := addr.(type) {
		default:
			return nil, errors.New("cannot make multisig script for " +
				"a non-secp256k1 public key or P2PKH address")
		case *bchutil.AddressPubKey:
			pubKeys[i] = addr
		case *bchutil.AddressPubKeyHash:
			if dbtx == nil {
				var err error
				dbtx, err = w.db.BeginReadTx()
				if err != nil {
					return nil, err
				}
				addrmgrNs = dbtx.ReadBucket(waddrmgrNamespaceKey)
			}
			addrInfo, err := w.Manager.Address(addrmgrNs, addr)
			if err != nil {
				return nil, err
			}
			serializedPubKey := addrInfo.(waddrmgr.ManagedPubKeyAddress).
				PubKey().SerializeCompressed()
			pubKeyAddr, err := bchutil.NewAddressPubKey(
				serializedPubKey, w.chainParams)
			if err != nil {
				return nil, err
			}
			pubKeys[i] = pubKeyAddr
		}
	}
	return txscript.MultiSigScript(pubKeys, nRequired)
}
MakeMultiSigScript creates a multi-signature script that can be redeemed with
nRequired signatures of the passed keys and addresses.  If the address is a
P2PKH address, the associated pubkey is looked up by the wallet if possible,
otherwise an error is returned for a missing pubkey.

This function only works with pubkeys and P2PKH addresses derived from them.
package wallet
import (
	"errors"
	"github.com/gcash/bchd/txscript"
	"github.com/gcash/bchutil"
	"github.com/gcash/bchwallet/waddrmgr"
	"github.com/gcash/bchwallet/walletdb"
)