mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-07-19 09:13:39 +00:00
small changes, comments
This commit is contained in:
@ -179,6 +179,11 @@ async fn submit_escrow_psbt(
|
|||||||
Json(payload): Json<PsbtSubmissionRequest>,
|
Json(payload): Json<PsbtSubmissionRequest>,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
panic!("implement")
|
panic!("implement")
|
||||||
|
|
||||||
|
// check if psbt is correct, valid and signed
|
||||||
|
// publish psbt if it is correct
|
||||||
|
// return 200 if everything is correct
|
||||||
|
// return 400 if something is wrong
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Will get polled by the traders once they submitted their PSBT part. The coorinator will return status code 200 once he received both PSBTs and they got mined,
|
/// Will get polled by the traders once they submitted their PSBT part. The coorinator will return status code 200 once he received both PSBTs and they got mined,
|
||||||
@ -192,6 +197,12 @@ async fn poll_escrow_confirmation(
|
|||||||
Json(payload): Json<OfferTakenRequest>,
|
Json(payload): Json<OfferTakenRequest>,
|
||||||
) -> Result<Response, AppError> {
|
) -> Result<Response, AppError> {
|
||||||
panic!("implement")
|
panic!("implement")
|
||||||
|
// let escrow_tx_txid = database.fetch_escrow_txid(&payload.order_id_hex).await?;
|
||||||
|
// if wallet.is_tx_confirmed(&escrow_tx_txid).await {
|
||||||
|
// Ok(StatusCode::OK.into_response())
|
||||||
|
// } else {
|
||||||
|
// Ok(StatusCode::ACCEPTED.into_response())
|
||||||
|
// } else if not found in database or not published (invalid request) return 404
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn submit_obligation_confirmation(
|
async fn submit_obligation_confirmation(
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// Obsolete trough usage of gettxspendingprevout, unfortunately bitcoincore_rpc does not support it yet
|
||||||
|
// doing upstream PR with gettxspendingprevout would make it possible to get rid of this internal mempool state
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use anyhow::Ok;
|
use anyhow::Ok;
|
||||||
use bdk::bitcoin::consensus::encode::deserialize;
|
use bdk::bitcoin::consensus::encode::deserialize;
|
||||||
|
@ -287,35 +287,46 @@ impl fmt::Debug for CoordinatorWallet<Tree> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use bdk::bitcoin::Network;
|
use bdk::bitcoin::Network;
|
||||||
use bdk::database::MemoryDatabase;
|
use bdk::database::MemoryDatabase;
|
||||||
use bdk::{blockchain::RpcBlockchain, Wallet};
|
use bdk::{blockchain::RpcBlockchain, Wallet};
|
||||||
async fn new_test_wallet(wallet_xprv: &str) -> CoordinatorWallet<MemoryDatabase> {
|
async fn new_test_wallet(wallet_xprv: &str) -> CoordinatorWallet<MemoryDatabase> {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
let wallet_xprv = ExtendedPrivKey::from_str(wallet_xprv).unwrap();
|
||||||
|
let secp_context = secp256k1::Secp256k1::new();
|
||||||
let rpc_config = RpcConfig {
|
let rpc_config = RpcConfig {
|
||||||
url: env::var("BITCOIN_RPC_ADDRESS_PORT").unwrap().to_string(),
|
url: env::var("BITCOIN_RPC_ADDRESS_PORT").unwrap().to_string(),
|
||||||
auth: Auth::Cookie {
|
auth: Auth::UserPass {
|
||||||
file: env::var("BITCOIN_RPC_COOKIE_FILE_PATH").unwrap().into(),
|
username: env::var("BITCOIN_RPC_USER").unwrap(),
|
||||||
|
password: env::var("BITCOIN_RPC_PASSWORD").unwrap(),
|
||||||
},
|
},
|
||||||
network: bdk::bitcoin::Network::Regtest,
|
network: Regtest,
|
||||||
wallet_name: env::var("BITCOIN_RPC_WALLET_NAME").unwrap(),
|
// wallet_name: env::var("BITCOIN_RPC_WALLET_NAME")?,
|
||||||
|
wallet_name: bdk::wallet::wallet_name_from_descriptor(
|
||||||
|
Bip86(wallet_xprv, KeychainKind::External),
|
||||||
|
Some(Bip86(wallet_xprv, KeychainKind::Internal)),
|
||||||
|
Network::Testnet,
|
||||||
|
&secp_context,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
sync_params: None,
|
sync_params: None,
|
||||||
};
|
};
|
||||||
let json_rpc_client =
|
let json_rpc_client =
|
||||||
Arc::new(Client::new(&rpc_config.url, rpc_config.auth.clone().into()).unwrap());
|
Arc::new(Client::new(&rpc_config.url, rpc_config.auth.clone().into()).unwrap());
|
||||||
let backend = RpcBlockchain::from_config(&rpc_config).unwrap();
|
let backend = RpcBlockchain::from_config(&rpc_config).unwrap();
|
||||||
|
|
||||||
let wallet_xprv = ExtendedPrivKey::from_str(wallet_xprv).unwrap();
|
|
||||||
let wallet = Wallet::new(
|
let wallet = Wallet::new(
|
||||||
Bip86(wallet_xprv, KeychainKind::External),
|
Bip86(wallet_xprv, KeychainKind::External),
|
||||||
Some(Bip86(wallet_xprv, KeychainKind::Internal)),
|
Some(Bip86(wallet_xprv, KeychainKind::Internal)),
|
||||||
Network::Regtest,
|
Network::Testnet,
|
||||||
MemoryDatabase::new(),
|
MemoryDatabase::new(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
wallet.sync(&backend, SyncOptions::default()).unwrap();
|
wallet.sync(&backend, SyncOptions::default()).unwrap();
|
||||||
|
tokio::time::sleep(Duration::from_secs(16)).await; // fetch the mempool
|
||||||
CoordinatorWallet::<MemoryDatabase> {
|
CoordinatorWallet::<MemoryDatabase> {
|
||||||
wallet: Arc::new(Mutex::new(wallet)),
|
wallet: Arc::new(Mutex::new(wallet)),
|
||||||
backend: Arc::new(backend),
|
backend: Arc::new(backend),
|
||||||
@ -324,6 +335,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the transactions are testnet4 transactions, so run a testnet4 rpc node as backend
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_transaction_without_signature() {
|
async fn test_transaction_without_signature() {
|
||||||
let test_wallet = new_test_wallet("tprv8ZgxMBicQKsPdHuCSjhQuSZP1h6ZTeiRqREYS5guGPdtL7D1uNLpnJmb2oJep99Esq1NbNZKVJBNnD2ZhuXSK7G5eFmmcx73gsoa65e2U32").await;
|
let test_wallet = new_test_wallet("tprv8ZgxMBicQKsPdHuCSjhQuSZP1h6ZTeiRqREYS5guGPdtL7D1uNLpnJmb2oJep99Esq1NbNZKVJBNnD2ZhuXSK7G5eFmmcx73gsoa65e2U32").await;
|
||||||
|
@ -87,7 +87,7 @@ impl TradingWallet {
|
|||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate input amount, escrow output
|
// validate amounts, escrow output
|
||||||
pub fn validate_maker_psbt(&self, psbt: &PartiallySignedTransaction) -> Result<&Self> {
|
pub fn validate_maker_psbt(&self, psbt: &PartiallySignedTransaction) -> Result<&Self> {
|
||||||
error!("IMPLEMENT MAKER PSBT VALIDATION!");
|
error!("IMPLEMENT MAKER PSBT VALIDATION!");
|
||||||
// tbd once the trade psbt is implemented on coordinator side
|
// tbd once the trade psbt is implemented on coordinator side
|
||||||
|
Reference in New Issue
Block a user