-
Notifications
You must be signed in to change notification settings - Fork 891
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
2,826 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
components/brave_wallet/browser/zcash/rust/extended_spending_key_impl.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#include "brave/components/brave_wallet/browser/zcash/rust/extended_spending_key_impl.h" | ||
|
||
#include <utility> | ||
|
||
#include "base/memory/ptr_util.h" | ||
|
||
namespace brave_wallet::orchard { | ||
|
||
ExtendedSpendingKeyImpl::ExtendedSpendingKeyImpl( | ||
absl::variant<base::PassKey<class ExtendedSpendingKey>, | ||
base::PassKey<class ExtendedSpendingKeyImpl>>, | ||
rust::Box<CxxOrchardExtendedSpendingKey> esk) | ||
: extended_spending_key_(std::move(esk)) {} | ||
|
||
ExtendedSpendingKeyImpl::~ExtendedSpendingKeyImpl() = default; | ||
|
||
std::unique_ptr<ExtendedSpendingKey> | ||
ExtendedSpendingKeyImpl::DeriveHardenedChild(uint32_t index) { | ||
auto esk = extended_spending_key_->derive(index); | ||
if (esk->is_ok()) { | ||
return std::make_unique<ExtendedSpendingKeyImpl>( | ||
base::PassKey<class ExtendedSpendingKeyImpl>(), esk->unwrap()); | ||
} | ||
return nullptr; | ||
} | ||
|
||
std::optional<OrchardAddrRawPart> | ||
ExtendedSpendingKeyImpl::GetDiversifiedAddress(uint32_t div_index, | ||
OrchardAddressKind kind) { | ||
return kind == OrchardAddressKind::External | ||
? extended_spending_key_->external_address(div_index) | ||
: extended_spending_key_->internal_address(div_index); | ||
} | ||
|
||
// static | ||
std::unique_ptr<ExtendedSpendingKey> ExtendedSpendingKey::GenerateFromSeed( | ||
base::span<const uint8_t> seed) { | ||
auto mk = generate_orchard_extended_spending_key_from_seed( | ||
rust::Slice<const uint8_t>{seed.data(), seed.size()}); | ||
if (mk->is_ok()) { | ||
return std::make_unique<ExtendedSpendingKeyImpl>( | ||
base::PassKey<class ExtendedSpendingKey>(), mk->unwrap()); | ||
} | ||
return nullptr; | ||
} | ||
|
||
OrchardFullViewKey ExtendedSpendingKeyImpl::GetFullViewKey() { | ||
return extended_spending_key_->full_view_key(); | ||
} | ||
|
||
OrchardSpendingKey ExtendedSpendingKeyImpl::GetSpendingKey() { | ||
return extended_spending_key_->spending_key(); | ||
} | ||
|
||
} // namespace brave_wallet::orchard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
components/brave_wallet/browser/zcash/zcash_action_context.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/components/brave_wallet/browser/zcash/zcash_action_context.h" | ||
|
||
namespace brave_wallet { | ||
|
||
ZCashActionContext::ZCashActionContext(ZCashRpc& zcash_rpc, | ||
#if BUILDFLAG(ENABLE_ORCHARD) | ||
base::SequenceBound<OrchardSyncState>& sync_state, | ||
#endif // BUILDFLAG(ENABLE_ORCHARD) | ||
const mojom::AccountIdPtr& account_id, | ||
const std::string& chain_id) : | ||
zcash_rpc(zcash_rpc), | ||
#if BUILDFLAG(ENABLE_ORCHARD) | ||
sync_state(sync_state), | ||
#endif // BUILDFLAG(ENABLE_ORCHARD) | ||
account_id(account_id.Clone()), | ||
chain_id(chain_id) {} | ||
|
||
ZCashActionContext& ZCashActionContext::operator=(ZCashActionContext&&) = default; | ||
ZCashActionContext::ZCashActionContext(ZCashActionContext&&) = default; | ||
|
||
ZCashActionContext::~ZCashActionContext() = default; | ||
|
||
} // namespace brave_wallet |
Oops, something went wrong.