begin with offer fetching

This commit is contained in:
f321x
2024-06-27 15:46:25 +00:00
parent ab59cd9db2
commit 465b67bb1a
3 changed files with 18 additions and 1 deletions

View File

@ -1,4 +1,4 @@
ELECTRUM_BACKEND="ssl://mempool.space:40002"
ELECTRUM_BACKEND="ssl://mempool.space:40002" # we need a node with large mempool size limit for monitoring to miss no bond transactions
DATABASE_PATH="./dbs/trades.db" # path to the coordinator sqlite database storing the trades
BDK_DB_PATH="./dbs/bdk-wallet" # Path to the BDK Sled database (no .db postfix)
WALLET_XPRV="tprv8ZgxMBicQKsPdHuCSjhQuSZP1h6ZTeiRqREYS5guGPdtL7D1uNLpnJmb2oJep99Esq1NbNZKVJBNnD2ZhuXSK7G5eFmmcx73gsoa65e2U32"

View File

@ -34,3 +34,9 @@ pub struct OrderActivatedResponse {
pub offer_id_hex: String,
pub bond_locked_until_timestamp: u64, // unix timestamp. Do not touch bond till then unless offer gets taken.
}
pub struct OffersRequest {
pub buy_offers: bool, // true if looking for buy offers, false if looking for sell offers
pub amount_min_sat: u64,
pub amount_max_sat: u64,
}

View File

@ -68,10 +68,21 @@ async fn submit_maker_bond(
}))
}
async fn fetch_available_offers(
Extension(database): Extension<CoordinatorDB>,
Extension(wallet): Extension<CoordinatorWallet>,
Json(payload): Json<OffersRequest>,
) -> Result<Json<Vec<PublicOffer>>, AppError> {
// let offers = database.fetch_available_offers(&payload).await?;
// Ok(Json(offers))
}
pub async fn api_server(database: CoordinatorDB, wallet: CoordinatorWallet) -> Result<()> {
let app = Router::new()
.route("/create-offer", post(receive_order))
.route("/submit-maker-bond", post(submit_maker_bond))
.route("/fetch-available-offers", post(fetch_available_offers))
.layer(Extension(database))
.layer(Extension(wallet));
// add other routes here