/**
  * generate multisig address for given path
  *
  * @param $path
  * @return array
  * @throws \Exception
  */
 protected function createAddress($path)
 {
     $path = BIP32Path::path($path);
     //build public keys for this path
     $primaryPubKey = $this->primaryPrivateKey->buildKey($path)->publicKey();
     $backupPubKey = $this->backupPrivateKey->buildKey($path->unhardenedPath())->publicKey();
     $blocktrailPubKey = $this->getBlocktrailPublicKey($path)->buildKey($path)->publicKey();
     //sort the keys
     $multisigKeys = BlocktrailSDK::sortMultisigKeys([$primaryPubKey, $backupPubKey, $blocktrailPubKey]);
     //create the multisig address
     $multiSig = RawTransaction::create_multisig(2, $multisigKeys);
     return [$multiSig['address'], $multiSig['redeemScript']];
 }
 /**
  * @param BIP32Key          $key
  * @param string|BIP32Path  $path
  * @return string[]                 [address, redeemScript]
  * @throws \Exception
  */
 protected function getRedeemScriptFromKey(BIP32Key $key, $path)
 {
     $path = BIP32Path::path($path)->publicPath();
     $blocktrailPublicKey = $this->getBlocktrailPublicKey($path);
     $multiSig = RawTransaction::create_multisig(2, BlocktrailSDK::sortMultisigKeys([$key->buildKey($path)->publicKey(), $this->backupPublicKey->buildKey($path->unhardenedPath())->publicKey(), $blocktrailPublicKey->buildKey($path)->publicKey()]));
     return [$multiSig['address'], $multiSig['redeemScript']];
 }