b7104cd654
* warning fixes * warning cleanup
59 lines
2.0 KiB
Rust
59 lines
2.0 KiB
Rust
// 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;
|
|
pub mod http;
|
|
mod slatepack;
|
|
|
|
pub use self::file::PathToSlate;
|
|
pub use self::http::HttpSlateSender;
|
|
pub use self::slatepack::PathToSlatepack;
|
|
|
|
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>;
|
|
}
|