mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-07-18 16:53:22 +00:00
small changes, comments
This commit is contained in:
@ -179,6 +179,11 @@ async fn submit_escrow_psbt(
|
||||
Json(payload): Json<PsbtSubmissionRequest>,
|
||||
) -> Result<Response, AppError> {
|
||||
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,
|
||||
@ -192,6 +197,12 @@ async fn poll_escrow_confirmation(
|
||||
Json(payload): Json<OfferTakenRequest>,
|
||||
) -> Result<Response, AppError> {
|
||||
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(
|
||||
|
@ -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 anyhow::Ok;
|
||||
use bdk::bitcoin::consensus::encode::deserialize;
|
||||
|
@ -287,35 +287,46 @@ impl fmt::Debug for CoordinatorWallet<Tree> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::time::Duration;
|
||||
|
||||
use super::*;
|
||||
use bdk::bitcoin::Network;
|
||||
use bdk::database::MemoryDatabase;
|
||||
use bdk::{blockchain::RpcBlockchain, Wallet};
|
||||
async fn new_test_wallet(wallet_xprv: &str) -> CoordinatorWallet<MemoryDatabase> {
|
||||
dotenv().ok();
|
||||
let wallet_xprv = ExtendedPrivKey::from_str(wallet_xprv).unwrap();
|
||||
let secp_context = secp256k1::Secp256k1::new();
|
||||
let rpc_config = RpcConfig {
|
||||
url: env::var("BITCOIN_RPC_ADDRESS_PORT").unwrap().to_string(),
|
||||
auth: Auth::Cookie {
|
||||
file: env::var("BITCOIN_RPC_COOKIE_FILE_PATH").unwrap().into(),
|
||||
auth: Auth::UserPass {
|
||||
username: env::var("BITCOIN_RPC_USER").unwrap(),
|
||||
password: env::var("BITCOIN_RPC_PASSWORD").unwrap(),
|
||||
},
|
||||
network: bdk::bitcoin::Network::Regtest,
|
||||
wallet_name: env::var("BITCOIN_RPC_WALLET_NAME").unwrap(),
|
||||
network: Regtest,
|
||||
// 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,
|
||||
};
|
||||
let json_rpc_client =
|
||||
Arc::new(Client::new(&rpc_config.url, rpc_config.auth.clone().into()).unwrap());
|
||||
let backend = RpcBlockchain::from_config(&rpc_config).unwrap();
|
||||
|
||||
let wallet_xprv = ExtendedPrivKey::from_str(wallet_xprv).unwrap();
|
||||
let wallet = Wallet::new(
|
||||
Bip86(wallet_xprv, KeychainKind::External),
|
||||
Some(Bip86(wallet_xprv, KeychainKind::Internal)),
|
||||
Network::Regtest,
|
||||
Network::Testnet,
|
||||
MemoryDatabase::new(),
|
||||
)
|
||||
.unwrap();
|
||||
wallet.sync(&backend, SyncOptions::default()).unwrap();
|
||||
|
||||
tokio::time::sleep(Duration::from_secs(16)).await; // fetch the mempool
|
||||
CoordinatorWallet::<MemoryDatabase> {
|
||||
wallet: Arc::new(Mutex::new(wallet)),
|
||||
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]
|
||||
async fn test_transaction_without_signature() {
|
||||
let test_wallet = new_test_wallet("tprv8ZgxMBicQKsPdHuCSjhQuSZP1h6ZTeiRqREYS5guGPdtL7D1uNLpnJmb2oJep99Esq1NbNZKVJBNnD2ZhuXSK7G5eFmmcx73gsoa65e2U32").await;
|
||||
|
@ -87,7 +87,7 @@ impl TradingWallet {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
// validate input amount, escrow output
|
||||
// validate amounts, escrow output
|
||||
pub fn validate_maker_psbt(&self, psbt: &PartiallySignedTransaction) -> Result<&Self> {
|
||||
error!("IMPLEMENT MAKER PSBT VALIDATION!");
|
||||
// tbd once the trade psbt is implemented on coordinator side
|
||||
|
Reference in New Issue
Block a user