mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-08 06:08:08 -05:00
WIP
This commit is contained in:
parent
2f19222948
commit
c3b8c7fbdb
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -2132,6 +2132,18 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "monero-wallet"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"curve25519-dalek",
|
||||||
|
"monero",
|
||||||
|
"monero-harness",
|
||||||
|
"rand 0.7.3",
|
||||||
|
"testcontainers 0.12.0",
|
||||||
|
"tokio 1.4.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "multihash"
|
name = "multihash"
|
||||||
version = "0.13.2"
|
version = "0.13.2"
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["monero-harness", "monero-rpc", "swap"]
|
members = ["monero-harness", "monero-rpc", "swap", "monero-wallet"]
|
||||||
|
@ -55,7 +55,7 @@ impl<'c> Monero {
|
|||||||
/// miner wallet container name is: `miner`
|
/// miner wallet container name is: `miner`
|
||||||
pub async fn new(
|
pub async fn new(
|
||||||
cli: &'c Cli,
|
cli: &'c Cli,
|
||||||
additional_wallets: Vec<String>,
|
additional_wallets: Vec<&'static str>,
|
||||||
) -> Result<(Self, Vec<Container<'c, Cli, image::Monero>>)> {
|
) -> Result<(Self, Vec<Container<'c, Cli, image::Monero>>)> {
|
||||||
let prefix = format!("{}_", random_prefix());
|
let prefix = format!("{}_", random_prefix());
|
||||||
let monerod_name = format!("{}{}", prefix, MONEROD_DAEMON_CONTAINER_NAME);
|
let monerod_name = format!("{}{}", prefix, MONEROD_DAEMON_CONTAINER_NAME);
|
||||||
|
16
monero-wallet/Cargo.toml
Normal file
16
monero-wallet/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[package]
|
||||||
|
name = "monero-wallet"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["CoBloX Team <team@coblox.tech>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
monero = "0.11"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
monero-harness = { path = "../monero-harness" }
|
||||||
|
tokio = { version = "1", features = ["rt-multi-thread", "time", "macros", "sync", "process", "fs"] }
|
||||||
|
testcontainers = "0.12"
|
||||||
|
monero = "0.11"
|
||||||
|
curve25519-dalek = "3"
|
||||||
|
rand = "0.7"
|
57
monero-wallet/src/lib.rs
Normal file
57
monero-wallet/src/lib.rs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use curve25519_dalek::scalar::Scalar;
|
||||||
|
use monero::blockdata::transaction::TxOutTarget;
|
||||||
|
use monero::blockdata::TransactionPrefix;
|
||||||
|
use monero::consensus::encode::VarInt;
|
||||||
|
use monero::{TxIn, TxOut};
|
||||||
|
use monero_harness::Monero;
|
||||||
|
use testcontainers::*;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn can_broadcast_locally_signed_transaction() {
|
||||||
|
let cli = clients::Cli::default();
|
||||||
|
let (monero, containers) = Monero::new(&cli, vec!["Alice"]).await.unwrap();
|
||||||
|
|
||||||
|
let view_key = monero::PrivateKey::from_scalar(Scalar::random(&mut rand::thread_rng()));
|
||||||
|
let spend_key = monero::PrivateKey::from_scalar(Scalar::random(&mut rand::thread_rng()));
|
||||||
|
|
||||||
|
let public_view_key = monero::PublicKey::from_private_key(&view_key);
|
||||||
|
let public_spend_key = monero::PublicKey::from_private_key(&spend_key);
|
||||||
|
|
||||||
|
let address =
|
||||||
|
monero::Address::standard(monero::Network::Stagenet, public_spend_key, public_view_key);
|
||||||
|
let transfer = monero
|
||||||
|
.wallet("miner")
|
||||||
|
.unwrap()
|
||||||
|
.client()
|
||||||
|
.transfer(0, 100_000, &address.to_string())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// [k_image, k_image + offset_0, k_image + offset_0 + offset_1, ..]
|
||||||
|
let mut transaction = monero::Transaction::default();
|
||||||
|
transaction.prefix.version = VarInt(2);
|
||||||
|
transaction.prefix.inputs.push(TxIn::ToKey {
|
||||||
|
amount: VarInt(0),
|
||||||
|
k_image: todo!(),
|
||||||
|
key_offsets: Vec::new(),
|
||||||
|
});
|
||||||
|
transaction.prefix.outputs.push(TxOut {
|
||||||
|
amount: VarInt(0),
|
||||||
|
target: TxOutTarget::ToKey {
|
||||||
|
key: monero
|
||||||
|
.wallet("alice")
|
||||||
|
.unwrap()
|
||||||
|
.client()
|
||||||
|
.get_address(0)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.address
|
||||||
|
.parse::<monero::Address>()
|
||||||
|
.unwrap()
|
||||||
|
.public_spend,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user