mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Minor work on the transaction signing task
This commit is contained in:
@@ -10,11 +10,26 @@ use group::GroupEncoding;
|
||||
use serai_db::DbTxn;
|
||||
|
||||
/// A signable transaction.
|
||||
pub trait SignableTransaction: 'static + Sized + Send + Sync {
|
||||
pub trait SignableTransaction: 'static + Sized + Send + Sync + Clone {
|
||||
/// The ciphersuite used to sign this transaction.
|
||||
type Ciphersuite: Cuphersuite;
|
||||
/// The preprocess machine for the signing protocol for this transaction.
|
||||
type PreprocessMachine: PreprocessMachine;
|
||||
|
||||
/// Read a `SignableTransaction`.
|
||||
fn read(reader: &mut impl io::Read) -> io::Result<Self>;
|
||||
/// Write a `SignableTransaction`.
|
||||
fn write(&self, writer: &mut impl io::Write) -> io::Result<()>;
|
||||
|
||||
/// The ID for this transaction.
|
||||
///
|
||||
/// This is an internal ID arbitrarily definable so long as it's unique.
|
||||
///
|
||||
/// This same ID MUST be returned by the Eventuality for this transaction.
|
||||
fn id(&self) -> [u8; 32];
|
||||
|
||||
/// Sign this transaction.
|
||||
fn sign(self, keys: ThresholdKeys<Self::Ciphersuite>) -> Self::PreprocessMachine;
|
||||
}
|
||||
|
||||
mod db {
|
||||
|
||||
@@ -309,6 +309,8 @@ impl<S: ScannerFeed, P: TransactionPlanner<S, ()>> Scheduler<S, P> {
|
||||
}
|
||||
|
||||
impl<S: ScannerFeed, P: TransactionPlanner<S, ()>> SchedulerTrait<S> for Scheduler<S, P> {
|
||||
type SignableTransaction = P::SignableTransaction;
|
||||
|
||||
fn activate_key(txn: &mut impl DbTxn, key: KeyFor<S>) {
|
||||
for coin in S::NETWORK.coins() {
|
||||
assert!(Db::<S>::outputs(txn, key, *coin).is_none());
|
||||
|
||||
@@ -368,6 +368,8 @@ impl<S: ScannerFeed, P: TransactionPlanner<S, EffectedReceivedOutputs<S>>> Sched
|
||||
impl<S: ScannerFeed, P: TransactionPlanner<S, EffectedReceivedOutputs<S>>> SchedulerTrait<S>
|
||||
for Scheduler<S, P>
|
||||
{
|
||||
type SignableTransaction = P::SignableTransaction;
|
||||
|
||||
fn activate_key(txn: &mut impl DbTxn, key: KeyFor<S>) {
|
||||
for coin in S::NETWORK.coins() {
|
||||
assert!(Db::<S>::outputs(txn, key, *coin).is_none());
|
||||
|
||||
Reference in New Issue
Block a user