1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Wallet trait

use cardano_serialization_lib as csl;
use plutus_ledger_api::v2::address::Address;
use plutus_ledger_api::v2::crypto::Ed25519PubKeyHash;
use thiserror::Error;

/// Cardano wallet that has access to a private key (directly or indirectly)
/// and able to sign a transaction
pub trait Wallet {
    /// Signs a fully built transaction
    fn sign_transaction(&self, tx: &csl::Transaction) -> csl::Transaction;

    /// Query the public key hash used by this wallet
    fn get_change_pkh(&self) -> Ed25519PubKeyHash;

    /// Query the wallet address
    fn get_change_addr(&self) -> Address;
}

#[derive(Error, Debug)]
#[error(transparent)]
pub struct WalletError(pub anyhow::Error);