mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 03:59:22 +00:00
Bitcoin TransactionPublisher
This commit is contained in:
parent
017aab2258
commit
c988b7cdb0
6 changed files with 19 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -8143,6 +8143,7 @@ dependencies = [
|
|||
"serai-processor-primitives",
|
||||
"serai-processor-scanner",
|
||||
"serai-processor-scheduler-primitives",
|
||||
"serai-processor-signers",
|
||||
"serai-processor-transaction-chaining-scheduler",
|
||||
"serai-processor-utxo-scheduler-primitives",
|
||||
"tokio",
|
||||
|
|
|
@ -47,6 +47,7 @@ scheduler = { package = "serai-processor-scheduler-primitives", path = "../sched
|
|||
scanner = { package = "serai-processor-scanner", path = "../scanner" }
|
||||
utxo-scheduler = { package = "serai-processor-utxo-scheduler-primitives", path = "../scheduler/utxo/primitives" }
|
||||
transaction-chaining-scheduler = { package = "serai-processor-transaction-chaining-scheduler", path = "../scheduler/utxo/transaction-chaining" }
|
||||
signers = { package = "serai-processor-signers", path = "../signers" }
|
||||
|
||||
message-queue = { package = "serai-message-queue", path = "../../message-queue" }
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ mod transaction;
|
|||
mod block;
|
||||
|
||||
// App-logic trait satisfactions
|
||||
mod scanner_feed;
|
||||
mod rpc;
|
||||
mod scheduler;
|
||||
|
||||
pub(crate) fn hash_bytes(hash: bitcoin_serai::bitcoin::hashes::sha256d::Hash) -> [u8; 32] {
|
||||
|
|
|
@ -3,8 +3,12 @@ use bitcoin_serai::rpc::{RpcError, Rpc as BRpc};
|
|||
use serai_client::primitives::{NetworkId, Coin, Amount};
|
||||
|
||||
use scanner::ScannerFeed;
|
||||
use signers::TransactionPublisher;
|
||||
|
||||
use crate::block::{BlockHeader, Block};
|
||||
use crate::{
|
||||
transaction::Transaction,
|
||||
block::{BlockHeader, Block},
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct Rpc(BRpc);
|
||||
|
@ -92,3 +96,12 @@ impl ScannerFeed for Rpc {
|
|||
Ok(Amount(0))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl TransactionPublisher<Transaction> for Rpc {
|
||||
type EphemeralError = RpcError;
|
||||
|
||||
async fn publish(&self, tx: Transaction) -> Result<(), Self::EphemeralError> {
|
||||
self.0.send_raw_transaction(&tx.0).await.map(|_| ())
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
scan::{offsets_for_key, scanner},
|
||||
output::Output,
|
||||
transaction::{SignableTransaction, Eventuality},
|
||||
scanner_feed::Rpc,
|
||||
rpc::Rpc,
|
||||
};
|
||||
|
||||
fn address_from_serai_key(key: <Secp256k1 as Ciphersuite>::G, kind: OutputType) -> Address {
|
||||
|
|
|
@ -24,7 +24,7 @@ use serai_client::networks::bitcoin::Address;
|
|||
use crate::output::OutputId;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct Transaction(BTransaction);
|
||||
pub(crate) struct Transaction(pub(crate) BTransaction);
|
||||
|
||||
impl From<BTransaction> for Transaction {
|
||||
fn from(tx: BTransaction) -> Self {
|
||||
|
|
Loading…
Reference in a new issue