|
7 | 7 | #include <ctime>
|
8 | 8 | #include <sstream>
|
9 | 9 | #include <map>
|
| 10 | +#include <memory> |
| 11 | +#include <utility> |
10 | 12 |
|
11 | 13 | #include "bat/ledger/internal/bat_client.h"
|
12 | 14 | #include "bat/ledger/internal/bat_helper.h"
|
@@ -313,7 +315,6 @@ void BatClient::WalletPropertiesCallback(
|
313 | 315 |
|
314 | 316 | std::string BatClient::getWalletPassphrase() const {
|
315 | 317 | braveledger_bat_helper::WALLET_INFO_ST wallet_info = ledger_->GetWalletInfo();
|
316 |
| - DCHECK(wallet_info.keyInfoSeed_.size()); |
317 | 318 | std::string passPhrase;
|
318 | 319 | if (wallet_info.keyInfoSeed_.size() == 0) {
|
319 | 320 | return passPhrase;
|
@@ -376,7 +377,7 @@ void BatClient::OnNicewareListLoaded(const std::string& pass_phrase,
|
376 | 377 | }
|
377 | 378 |
|
378 | 379 | void BatClient::continueRecover(int result,
|
379 |
| - size_t *written, |
| 380 | + size_t* written, |
380 | 381 | const std::vector<uint8_t>& newSeed) {
|
381 | 382 | if (result != 0 || *written == 0) {
|
382 | 383 | BLOG(ledger_, ledger::LogLevel::LOG_INFO)
|
@@ -480,6 +481,15 @@ ledger_->LogResponse(__func__, response_status_code, response, headers);
|
480 | 481 |
|
481 | 482 | void BatClient::getGrants(const std::string& lang,
|
482 | 483 | const std::string& forPaymentId) {
|
| 484 | + // make sure wallet/client state is sane here as this is the first |
| 485 | + // panel call. |
| 486 | + const std::string& wallet_payment_id = ledger_->GetPaymentId(); |
| 487 | + const std::string& passphrase = ledger_->GetWalletPassphrase(); |
| 488 | + if (wallet_payment_id.empty() || passphrase.empty()) { |
| 489 | + braveledger_bat_helper::WALLET_PROPERTIES_ST properties; |
| 490 | + ledger_->OnWalletProperties(ledger::Result::CORRUPTED_WALLET, properties); |
| 491 | + return; |
| 492 | + } |
483 | 493 | std::string paymentId = forPaymentId;
|
484 | 494 | if (paymentId.empty()) {
|
485 | 495 | paymentId = ledger_->GetPaymentId();
|
|
0 commit comments