Ejemplo n.º 1
0
 /**
  * upgrade wallet to different blocktrail cosign key
  *
  * @param $keyIndex
  * @return bool
  * @throws \Exception
  */
 public function upgradeKeyIndex($keyIndex)
 {
     if ($this->locked) {
         throw new \Exception("Wallet needs to be unlocked to upgrade key index");
     }
     $walletPath = WalletPath::create($keyIndex);
     // do the upgrade to the new 'key_index'
     $primaryPublicKey = BIP32::extended_private_to_public(BIP32::build_key($this->primaryPrivateKey->tuple(), (string) $walletPath->keyIndexPath()));
     $result = $this->sdk->upgradeKeyIndex($this->identifier, $keyIndex, $primaryPublicKey);
     $this->primaryPublicKeys[$keyIndex] = BIP32Key::create($primaryPublicKey);
     $this->keyIndex = $keyIndex;
     $this->walletPath = $walletPath;
     // update the blocktrail public keys
     foreach ($result['blocktrail_public_keys'] as $keyIndex => $pubKey) {
         if (!isset($this->blocktrailPublicKeys[$keyIndex])) {
             $this->blocktrailPublicKeys[$keyIndex] = BIP32Key::create($pubKey);
         }
     }
     return true;
 }