diff --git a/taptrade-cli-demo/coordinator/src/communication/api.rs b/taptrade-cli-demo/coordinator/src/communication/api.rs index 180a00f..bc158c1 100644 --- a/taptrade-cli-demo/coordinator/src/communication/api.rs +++ b/taptrade-cli-demo/coordinator/src/communication/api.rs @@ -73,3 +73,10 @@ pub struct OfferTakenRequest { pub robohash_hex: String, pub order_id_hex: String, } + +#[derive(Debug, Serialize, Deserialize)] +pub struct PsbtSubmissionRequest { + pub signed_psbt_hex: String, + pub offer_id_hex: String, + pub robohash_hex: String, +} diff --git a/taptrade-cli-demo/coordinator/src/communication/mod.rs b/taptrade-cli-demo/coordinator/src/communication/mod.rs index fa9d26a..4011266 100755 --- a/taptrade-cli-demo/coordinator/src/communication/mod.rs +++ b/taptrade-cli-demo/coordinator/src/communication/mod.rs @@ -19,7 +19,7 @@ use tokio::net::TcpListener; // // Axum handler functions // -// Handler function to process the received data +/// Handler function to process the received data async fn receive_order( Extension(database): Extension, Extension(wallet): Extension, @@ -40,6 +40,7 @@ async fn receive_order( Ok(Json(bond_requirements)) } +/// receives the maker bond, verifies it and moves to offer to the active table (orderbook) async fn submit_maker_bond( Extension(database): Extension, Extension(wallet): Extension, @@ -73,6 +74,7 @@ async fn submit_maker_bond( .into_response()) } +/// returns available offers from the active table (orderbook) async fn fetch_available_offers( Extension(database): Extension, Json(payload): Json, @@ -82,6 +84,8 @@ async fn fetch_available_offers( Ok(Json(PublicOffers { offers })) } +/// receives the taker bond for a given offer, verifies it, creates escrow transaction psbt +/// and moves the offer to the taken table. Will return the trade contract psbt for the taker to sign. async fn submit_taker_bond( Extension(database): Extension, Extension(wallet): Extension, @@ -120,6 +124,7 @@ async fn submit_taker_bond( .into_response()) } +/// gets polled by the maker and returns the escrow psbt in case the offer has been taken async fn request_offer_status_maker( Extension(database): Extension, Json(payload): Json, @@ -136,6 +141,39 @@ async fn request_offer_status_maker( } } +/// receives the signed escrow psbt and verifies it +async fn submit_escrow_psbt( + Extension(database): Extension, + Extension(wallet): Extension, + Json(payload): Json, +) -> Result { + panic!("implement") +} + +async fn poll_escrow_confirmation( + Extension(database): Extension, + Extension(wallet): Extension, + Json(payload): Json, +) -> Result { + panic!("implement") +} + +async fn submit_obligation_confirmation( + Extension(database): Extension, + Extension(wallet): Extension, + Json(payload): Json, +) -> Result { + panic!("implement") +} + +async fn poll_final_payout( + Extension(database): Extension, + Extension(wallet): Extension, + Json(payload): Json, +) -> Result { + panic!("implement") +} + pub async fn api_server(database: CoordinatorDB, wallet: CoordinatorWallet) -> Result<()> { let app = Router::new() .route("/create-offer", post(receive_order)) @@ -143,6 +181,13 @@ pub async fn api_server(database: CoordinatorDB, wallet: CoordinatorWallet) -> R .route("/fetch-available-offers", post(fetch_available_offers)) .route("/submit-taker-bond", post(submit_taker_bond)) .route("/request-offer-status", post(request_offer_status_maker)) + .route("/submit-escrow-psbt", post(submit_escrow_psbt)) + .route("/poll-escrow-confirmation", post(poll_escrow_confirmation)) + .route( + "/submit-obligation-confirmation", + post(submit_obligation_confirmation), + ) + .route("/poll-final-payout", post(poll_final_payout)) .layer(Extension(database)) .layer(Extension(wallet)); // add other routes here diff --git a/taptrade-cli-demo/trader/src/communication/mod.rs b/taptrade-cli-demo/trader/src/communication/mod.rs index 1f92842..50b14a0 100644 --- a/taptrade-cli-demo/trader/src/communication/mod.rs +++ b/taptrade-cli-demo/trader/src/communication/mod.rs @@ -192,7 +192,7 @@ impl IsOfferReadyRequest { let res = client .post(format!( "{}{}", - taker_config.coordinator_endpoint, "/poll-offer-status" + taker_config.coordinator_endpoint, "/poll-escrow-confirmation" )) .json(&request) .send()?;