Пример #1
0
 protected function _createTestWallet(BlocktrailSDKInterface $client, $identifier, $passphrase, $primaryMnemonic, $backupMnemonic, $readOnly = false)
 {
     $walletPath = WalletPath::create(9999);
     $seed = BIP39::mnemonicToSeedHex($primaryMnemonic, $passphrase);
     $primaryPrivateKey = BIP32::master_key($seed, 'bitcoin', true);
     $primaryPublicKey = BIP32::build_key($primaryPrivateKey, (string) $walletPath->keyIndexPath()->publicPath());
     $seed = BIP39::mnemonicToSeedHex($backupMnemonic, "");
     $backupPrivateKey = BIP32::master_key($seed, 'bitcoin', true);
     $backupPublicKey = BIP32::build_key($backupPrivateKey, (string) "M");
     $testnet = true;
     $checksum = BIP32::key_to_address($primaryPrivateKey[0]);
     $result = $client->_createNewWallet($identifier, $primaryPublicKey, $backupPublicKey, $primaryMnemonic, $checksum, 9999);
     $blocktrailPublicKeys = $result['blocktrail_public_keys'];
     $keyIndex = $result['key_index'];
     $wallet = new Wallet($client, $identifier, $primaryMnemonic, [$keyIndex => $primaryPublicKey], $backupPublicKey, $blocktrailPublicKeys, $keyIndex, 'bitcoin', $testnet, $checksum);
     if (!$readOnly) {
         $wallet->unlock(['password' => $passphrase]);
     }
     return $wallet;
 }
Пример #2
0
 /**
  * get all UTXOs for the wallet (paginated)
  *
  * @param  integer $page    pagination: page number
  * @param  integer $limit   pagination: records per page (max 500)
  * @param  string  $sortDir pagination: sort direction (asc|desc)
  * @return array            associative array containing the response
  */
 public function utxos($page = 1, $limit = 20, $sortDir = 'asc')
 {
     return $this->sdk->walletUTXOs($this->identifier, $page, $limit, $sortDir);
 }