forked from mimblewimble/grin-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
58 lines (51 loc) · 1.97 KB
/
Copy pathmod.rs
File metadata and controls
58 lines (51 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2021 The Grin Developers
//
// 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.
mod file;
mod slatepack;
pub mod tor;
pub use self::file::PathToSlate;
pub use self::slatepack::PathToSlatepack;
pub use self::tor::TorSlateSender;
use crate::config::WalletConfig;
use crate::libwallet::{Error, Slate};
use crate::util::ZeroingString;
/// Sends transactions to a corresponding SlateReceiver
pub trait SlateSender {
/// Send a transaction slate to another listening wallet and return result
/// TODO: Probably need a slate wrapper type
fn send_tx(&mut self, slate: &Slate, finalize: bool) -> Result<Slate, Error>;
}
pub trait SlateReceiver {
/// Start a listener, passing received messages to the wallet api directly
/// Takes a wallet config for now to avoid needing all sorts of awkward
/// type parameters on this trait
fn listen(
&self,
config: WalletConfig,
passphrase: ZeroingString,
account: &str,
node_api_secret: Option<String>,
) -> Result<(), Error>;
}
/// Posts slates to be read later by a corresponding getter
pub trait SlatePutter {
/// Send a transaction asynchronously
fn put_tx(&self, slate: &Slate, as_bin: bool) -> Result<(), Error>;
}
/// Checks for a transaction from a corresponding SlatePutter, returns the transaction if it exists
pub trait SlateGetter {
/// Receive a transaction async. (Actually just read it from wherever and return the slate).
/// Returns (Slate, whether it was in binary form)
fn get_tx(&self) -> Result<(Slate, bool), Error>;
}