Skip to content

Commit a2ef81a

Browse files
committed
updated validate
1 parent 32d6124 commit a2ef81a

2 files changed

Lines changed: 46 additions & 11 deletions

File tree

lib/ain-ocean/src/api/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod masternode;
1111
mod oracle;
1212
mod pool_pair;
1313
pub mod prices;
14-
// mod rawtx;
14+
mod rawtx;
1515
mod cache;
1616
pub mod common;
1717
mod path;

lib/ain-ocean/src/api/rawtx.rs

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,62 @@
11
use std::sync::Arc;
2-
use crate::model::RawTx;
2+
use crate::{
3+
error::{ApiError, Error, NotFoundKind},
4+
model::RawTx,
5+
repository::RepositoryOps,
6+
storage::SortOrder,
7+
Result,
8+
};
9+
use super::{
10+
query::PaginationQuery,
11+
response::{ApiPagedResponse, Response},
12+
AppContext,
13+
};
314
use axum::{
4-
routing::{get, post},
5-
Router,
15+
extract::{Path, Query},
16+
routing::{get,post},
17+
Extension, Router,
618
};
719
use defichain_rpc::{Client, RpcApi};
8-
use super::path::Path;
920

10-
async fn send_rawtx() -> String {
11-
"Sending raw transaction".to_string()
21+
use ain_macros::ocean_endpoint;
22+
23+
#[ocean_endpoint]
24+
async fn send_rawtx(
25+
Path(tx): Path<RawTx>,
26+
Extension(ctx): Extension<Arc<AppContext>>,
27+
) -> Result<Response<String>> {
28+
29+
Ok(Response::new("Sending raw transaction".to_string()))
1230
}
1331

14-
async fn test_rawtx() -> String {
15-
"Testing raw transaction".to_string()
32+
#[ocean_endpoint]
33+
async fn test_rawtx(
34+
Path(tx): Path<RawTx>,
35+
Extension(ctx): Extension<Arc<AppContext>>,
36+
) -> Result<Response<String>> {
37+
38+
Ok(Response::new("Testing raw transaction".to_string()))
39+
}
40+
#[ocean_endpoint]
41+
async fn get_rawtx(
42+
Path(txid): Path<String>,
43+
Extension(ctx): Extension<Arc<AppContext>>,
44+
) -> Result<Response<String>> {
45+
format!("Details of raw transaction with txid {}", txid);
46+
Ok(Response::new("Testing raw transaction".to_string()))
1647
}
1748

18-
async fn get_rawtx(Path(txid): Path<String>) -> String {
19-
format!("Details of raw transaction with txid {}", txid)
49+
async fn validate(hex:String) {
50+
if !hex.starts_with("040000000001") {
51+
return
52+
}
53+
2054
}
2155

2256
pub fn router(ctx: Arc<AppContext>) -> Router {
2357
Router::new()
2458
.route("/send", post(send_rawtx))
2559
.route("/test", get(test_rawtx))
2660
.route("/:txid", get(get_rawtx))
61+
.layer(Extension(ctx))
2762
}

0 commit comments

Comments
 (0)