Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions src/BlocktrailSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,8 @@ protected function createNewWalletV1($options) {
$primaryMnemonic,
$checksum,
$options['key_index'],
array_key_exists('segwit', $options) ? $options['segwit'] : false
array_key_exists('segwit', $options) ? $options['segwit'] : false,
array_key_exists('require_activation', $options) ? $options['require_activation'] : false
);

// received the blocktrail public keys
Expand Down Expand Up @@ -859,7 +860,8 @@ protected function createNewWalletV2($options) {
$storeDataOnServer ? $recoverySecret : false,
$checksum,
$options['key_index'],
array_key_exists('segwit', $options) ? $options['segwit'] : false
array_key_exists('segwit', $options) ? $options['segwit'] : false,
array_key_exists('require_activation', $options) ? $options['require_activation'] : false
);

// received the blocktrail public keys
Expand Down Expand Up @@ -1004,7 +1006,8 @@ protected function createNewWalletV3($options) {
$storeDataOnServer ? $recoverySecret->getHex() : false,
$checksum,
$options['key_index'],
array_key_exists('segwit', $options) ? $options['segwit'] : false
array_key_exists('segwit', $options) ? $options['segwit'] : false,
array_key_exists('require_activation', $options) ? $options['require_activation'] : false
);

// received the blocktrail public keys
Expand Down Expand Up @@ -1084,9 +1087,12 @@ private function verifyPublicOnly(array $walletData) {
* @param string $checksum checksum to store
* @param int $keyIndex account that we expect to use
* @param bool $segwit opt in to segwit
* @param bool $requireActivation require wallet to be activated by another endpoint
* @return mixed
* @throws BlocktrailSDKException
* @throws \Exception
*/
public function storeNewWalletV1($identifier, $primaryPublicKey, $backupPublicKey, $primaryMnemonic, $checksum, $keyIndex, $segwit = false) {
public function storeNewWalletV1($identifier, $primaryPublicKey, $backupPublicKey, $primaryMnemonic, $checksum, $keyIndex, $segwit = false, $requireActivation = false) {
$data = [
'identifier' => $identifier,
'primary_public_key' => $primaryPublicKey,
Expand All @@ -1096,6 +1102,9 @@ public function storeNewWalletV1($identifier, $primaryPublicKey, $backupPublicKe
'key_index' => $keyIndex,
'segwit' => $segwit,
];
if ($requireActivation) {
$data['require_activation'] = true;
}
$this->verifyPublicOnly($data);
$response = $this->blocktrailClient->post("wallet", null, $data, RestClient::AUTH_HTTP_SIG);
return self::jsonDecode($response->body(), true);
Expand All @@ -1113,10 +1122,12 @@ public function storeNewWalletV1($identifier, $primaryPublicKey, $backupPublicKe
* @param string $checksum checksum to store
* @param int $keyIndex account that we expect to use
* @param bool $segwit opt in to segwit
* @param bool $requireActivation require wallet to be activated by another endpoint
* @return mixed
* @throws BlocktrailSDKException
* @throws \Exception
*/
public function storeNewWalletV2($identifier, $primaryPublicKey, $backupPublicKey, $encryptedPrimarySeed, $encryptedSecret, $recoverySecret, $checksum, $keyIndex, $segwit = false) {
public function storeNewWalletV2($identifier, $primaryPublicKey, $backupPublicKey, $encryptedPrimarySeed, $encryptedSecret, $recoverySecret, $checksum, $keyIndex, $segwit = false, $requireActivation = false) {
$data = [
'identifier' => $identifier,
'wallet_version' => Wallet::WALLET_VERSION_V2,
Expand All @@ -1129,6 +1140,9 @@ public function storeNewWalletV2($identifier, $primaryPublicKey, $backupPublicKe
'key_index' => $keyIndex,
'segwit' => $segwit,
];
if ($requireActivation) {
$data['require_activation'] = true;
}
$this->verifyPublicOnly($data);
$response = $this->blocktrailClient->post("wallet", null, $data, RestClient::AUTH_HTTP_SIG);
return self::jsonDecode($response->body(), true);
Expand All @@ -1146,11 +1160,12 @@ public function storeNewWalletV2($identifier, $primaryPublicKey, $backupPublicKe
* @param string $checksum checksum to store
* @param int $keyIndex account that we expect to use
* @param bool $segwit opt in to segwit
* @param bool $requireActivation require wallet to be activated by another endpoint
* @return mixed
* @throws BlocktrailSDKException
* @throws \Exception
*/
public function storeNewWalletV3($identifier, $primaryPublicKey, $backupPublicKey, $encryptedPrimarySeed, $encryptedSecret, $recoverySecret, $checksum, $keyIndex, $segwit = false) {

public function storeNewWalletV3($identifier, $primaryPublicKey, $backupPublicKey, $encryptedPrimarySeed, $encryptedSecret, $recoverySecret, $checksum, $keyIndex, $segwit = false, $requireActivation = false) {
$data = [
'identifier' => $identifier,
'wallet_version' => Wallet::WALLET_VERSION_V3,
Expand All @@ -1163,7 +1178,9 @@ public function storeNewWalletV3($identifier, $primaryPublicKey, $backupPublicKe
'key_index' => $keyIndex,
'segwit' => $segwit,
];

if ($requireActivation) {
$data['require_activation'] = true;
}
$this->verifyPublicOnly($data);
$response = $this->blocktrailClient->post("wallet", null, $data, RestClient::AUTH_HTTP_SIG);
return self::jsonDecode($response->body(), true);
Expand Down