-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet: use new history API. Remve interfaces dependency
- Loading branch information
1 parent
e3bb8e3
commit 406f80a
Showing
10 changed files
with
158 additions
and
190 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// RGB wallet library for smart contracts on Bitcoin & Lightning network | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Written in 2019-2023 by | ||
// Dr Maxim Orlovsky <[email protected]> | ||
// | ||
// Copyright (C) 2019-2023 LNP/BP Standards Association. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use bpwallet::Wallet; | ||
use rgbstd::interface::AssignmentsFilter; | ||
|
||
use crate::{DescriptorRgb, WalletProvider, XChain, XOutpoint, XWitnessId}; | ||
|
||
pub struct WalletOutpointsFilter<'a, K, D: DescriptorRgb<K>>(pub &'a Wallet<K, D>); | ||
|
||
// We need manual derivation to ensure we can be copied and cloned even if descriptor is not | ||
// copyable/clonable. | ||
impl<'a, K, D: DescriptorRgb<K>> Copy for WalletOutpointsFilter<'a, K, D> {} | ||
impl<'a, K, D: DescriptorRgb<K>> Clone for WalletOutpointsFilter<'a, K, D> { | ||
fn clone(&self) -> Self { *self } | ||
} | ||
|
||
impl<'a, K, D: DescriptorRgb<K>> AssignmentsFilter for WalletOutpointsFilter<'a, K, D> { | ||
fn should_include(&self, output: impl Into<XOutpoint>, _: Option<XWitnessId>) -> bool { | ||
let output = output.into(); | ||
self.0 | ||
.outpoints() | ||
.any(|outpoint| XChain::Bitcoin(outpoint) == *output) | ||
} | ||
} | ||
|
||
pub struct WitnessOutpointsFilter<'a, K, D: DescriptorRgb<K>>(pub &'a Wallet<K, D>); | ||
|
||
// We need manual derivation to ensure we can be copied and cloned even if descriptor is not | ||
// copyable/clonable. | ||
impl<'a, K, D: DescriptorRgb<K>> Copy for WitnessOutpointsFilter<'a, K, D> {} | ||
impl<'a, K, D: DescriptorRgb<K>> Clone for WitnessOutpointsFilter<'a, K, D> { | ||
fn clone(&self) -> Self { *self } | ||
} | ||
|
||
impl<'a, K, D: DescriptorRgb<K>> AssignmentsFilter for WitnessOutpointsFilter<'a, K, D> { | ||
fn should_include(&self, _: impl Into<XOutpoint>, witness_id: Option<XWitnessId>) -> bool { | ||
self.0 | ||
.history() | ||
.any(|row| witness_id == Some(XChain::Bitcoin(row.txid))) | ||
} | ||
} |
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
Oops, something went wrong.