test: align suite dintégration; docs: prérequis wasm-pack/clang; chore: warnings

This commit is contained in:
Your Name 2025-08-26 06:31:15 +02:00
parent 58aba5b713
commit 0f2ac94357
5 changed files with 94 additions and 96 deletions

View File

@ -17,7 +17,7 @@ wasm-logger = "0.2.0"
rand = "0.8.5" rand = "0.8.5"
tsify = { git = "https://github.com/Sosthene00/tsify", branch = "next" } tsify = { git = "https://github.com/Sosthene00/tsify", branch = "next" }
# sdk_common = { path = "../sdk_common" } # sdk_common = { path = "../sdk_common" }
sdk_common = { git = "https://git.4nkweb.com/4nk/sdk_common.git", branch = "dev" } sdk_common = { git = "https://git.4nkweb.com/4nk/sdk_common.git", branch = "docker-support" }
serde-wasm-bindgen = "0.6.5" serde-wasm-bindgen = "0.6.5"
js-sys = "0.3.77" js-sys = "0.3.77"

View File

@ -23,6 +23,15 @@ Répertoires fournis:
Exécution standard: unité, intégration, puis front WASM. Les seuils et critères sont définis cidessous. Exécution standard: unité, intégration, puis front WASM. Les seuils et critères sont définis cidessous.
### Prérequis tests WASM (headless)
- Outil: `wasm-pack` installé (via `cargo install wasm-pack`).
- Navigateurs: Chrome et/ou Firefox installés en local (mode headless supporté).
- Windows: installer LLVM/Clang et définir le compilateur C pour la cible WASM:
- Installer LLVM (ex. via `winget install -e --id LLVM.LLVM --accept-package-agreements --accept-source-agreements --silent`).
- Définir le compilateur dans la session: `CC="C:\\Program Files\\LLVM\\bin\\clang.exe"` et `CC_wasm32_unknown_unknown` identique.
- Lancer ensuite: `wasm-pack test --headless --chrome` et/ou `--firefox`.
Options disponibles : Options disponibles :
- `--verbose` : Mode verbose avec affichage détaillé - `--verbose` : Mode verbose avec affichage détaillé
- `--debug` : Mode debug complet - `--debug` : Mode debug complet

View File

@ -1,14 +1,12 @@
use std::collections::HashMap; use std::collections::HashMap;
use sdk_client::api::{ use sdk_client::api::{
create_connect_transaction, create_device_from_sp_wallet, dump_device, get_address, get_outputs, parse_cipher, reset_device, reset_shared_secrets, restore_device, set_shared_secrets, setup, ApiReturn create_device_from_sp_wallet, create_transaction, dump_device, get_address, get_outputs, parse_cipher, reset_device, reset_shared_secrets, restore_device, set_shared_secrets, setup
}; };
use sdk_common::log::debug; use sdk_common::log::debug;
use sdk_common::pcd::Member;
use sdk_common::secrets::SecretsStore; use sdk_common::secrets::SecretsStore;
use sdk_common::sp_client::bitcoin::OutPoint; use sdk_common::sp_client::bitcoin::OutPoint;
use sdk_common::sp_client::spclient::OwnedOutput; use sdk_common::sp_client::OwnedOutput;
use sdk_common::sp_client::silentpayments::utils::SilentPaymentAddress;
use tsify::JsValueSerdeExt; use tsify::JsValueSerdeExt;
use wasm_bindgen_test::*; use wasm_bindgen_test::*;
@ -62,6 +60,7 @@ wasm_bindgen_test_configure!(run_in_browser);
/// ## Verification: /// ## Verification:
/// - Finally, the function asserts that Alice and Bob now share the same secrets, confirming successful /// - Finally, the function asserts that Alice and Bob now share the same secrets, confirming successful
/// connection and mutual authentication between the devices. /// connection and mutual authentication between the devices.
#[wasm_bindgen_test]
fn test_connect() { fn test_connect() {
setup(); setup();
let mut alice_secrets_store = SecretsStore::new(); let mut alice_secrets_store = SecretsStore::new();
@ -83,8 +82,8 @@ fn test_connect() {
// We just send a transaction to Bob device to allow them to share encrypted message // We just send a transaction to Bob device to allow them to share encrypted message
// Since we're not paired we can just put bob's address in a disposable member // Since we're not paired we can just put bob's address in a disposable member
// create_connect_transaction needs to take members though because most of the time we'd rather create secrets with all the devices of a member // create_connect_transaction needs to take members though because most of the time we'd rather create secrets with all the devices of a member
let bob_member = Member::new(vec![SilentPaymentAddress::try_from(bob_address.as_str()).unwrap()]).unwrap(); // Dans l'API actuelle, on crée directement une transaction vers les adresses SP
let alice_connect_return = create_connect_transaction(vec![serde_json::to_string(&bob_member).unwrap()], 1).unwrap(); let alice_connect_return = create_transaction(vec![bob_address.clone()], 1).unwrap();
debug!("alice_connect_return: {:#?}", alice_connect_return); debug!("alice_connect_return: {:#?}", alice_connect_return);
@ -149,11 +148,11 @@ fn test_connect() {
// ======================= Alice // ======================= Alice
reset_device().unwrap(); reset_device().unwrap();
restore_device(alice_device).unwrap(); restore_device(serde_wasm_bindgen::to_value(&alice_device).unwrap()).unwrap();
set_shared_secrets(serde_json::to_string(&alice_secrets_store).unwrap()).unwrap(); set_shared_secrets(serde_json::to_string(&alice_secrets_store).unwrap()).unwrap();
debug!("Alice receives the connect Prd"); debug!("Alice receives the connect Prd");
let alice_parsed_connect = parse_cipher(bob_to_alice_cipher.clone()).unwrap(); let alice_parsed_connect = parse_cipher(bob_to_alice_cipher.clone(), sdk_common::serialization::OutPointMemberMap(std::collections::HashMap::new())).unwrap();
// debug!("alice_parsed_confirm: {:#?}", alice_parsed_confirm); // debug!("alice_parsed_confirm: {:#?}", alice_parsed_confirm);
@ -174,11 +173,11 @@ fn test_connect() {
// ======================= Bob // ======================= Bob
reset_device().unwrap(); reset_device().unwrap();
restore_device(bob_device).unwrap(); restore_device(serde_wasm_bindgen::to_value(&bob_device).unwrap()).unwrap();
set_shared_secrets(serde_json::to_string(&bob_secrets_store).unwrap()).unwrap(); set_shared_secrets(serde_json::to_string(&bob_secrets_store).unwrap()).unwrap();
debug!("Bob parses alice prd connect"); debug!("Bob parses alice prd connect");
let bob_parsed_connect = parse_cipher(alice_to_bob_cipher.clone()).unwrap(); let bob_parsed_connect = parse_cipher(alice_to_bob_cipher.clone(), sdk_common::serialization::OutPointMemberMap(std::collections::HashMap::new())).unwrap();
let updated_secrets = bob_parsed_connect.secrets.unwrap(); let updated_secrets = bob_parsed_connect.secrets.unwrap();
let updated_unconfirmed_secrets = updated_secrets.get_all_unconfirmed_secrets(); let updated_unconfirmed_secrets = updated_secrets.get_all_unconfirmed_secrets();

View File

@ -2,13 +2,15 @@ use std::collections::HashMap;
use std::str::FromStr; use std::str::FromStr;
use sdk_client::api::{ use sdk_client::api::{
create_device_from_sp_wallet, create_new_process, create_response_prd, create_update_message, dump_device, get_address, pair_device, parse_cipher, reset_device, restore_device, set_process_cache, set_shared_secrets, setup, update_process_state, validate_state create_device_from_sp_wallet, create_new_process, create_response_prd, create_update_message, dump_device, get_address, pair_device, parse_cipher, reset_device, restore_device, set_process_cache, set_shared_secrets, setup, update_process, validate_state
}; };
use sdk_common::crypto::AnkSharedSecretHash; use sdk_common::crypto::AnkSharedSecretHash;
use sdk_common::log::debug; use sdk_common::log::debug;
use sdk_common::pcd::{Member, Pcd, RoleDefinition}; use sdk_common::pcd::{Member, Pcd, Roles};
use sdk_common::serialization::OutPointMemberMap;
use serde_wasm_bindgen;
use sdk_common::secrets::SecretsStore; use sdk_common::secrets::SecretsStore;
use serde_json::{json, Map, Value}; use serde_json::{json};
use wasm_bindgen_test::*; use wasm_bindgen_test::*;
@ -123,8 +125,7 @@ fn test_pairing() {
let new_member = Member::new(vec![ let new_member = Member::new(vec![
alice_address.as_str().try_into().unwrap(), alice_address.as_str().try_into().unwrap(),
bob_address.as_str().try_into().unwrap(), bob_address.as_str().try_into().unwrap(),
]) ]);
.unwrap();
let initial_session_privkey = [0u8; 32]; // In reality we would generate a random new key here let initial_session_privkey = [0u8; 32]; // In reality we would generate a random new key here
let initial_session_pubkey = [0u8; 32]; let initial_session_pubkey = [0u8; 32];
@ -164,9 +165,14 @@ fn test_pairing() {
}); });
debug!("Alice creates the pairing process"); debug!("Alice creates the pairing process");
let create_process_return = create_new_process(pairing_init_state.to_string(), None, RELAY_ADDRESS.to_owned(), 1).unwrap(); // Construire Pcd et Roles à partir du JSON
let private_data: Pcd = TryInto::<Pcd>::try_into(pairing_init_state.clone()).unwrap();
let roles_value = pairing_init_state.get("roles").unwrap().clone();
let roles_map: Roles = serde_json::from_value(roles_value).unwrap();
let public_data: Pcd = Default::default();
let create_process_return = create_new_process(private_data, roles_map.clone(), public_data, RELAY_ADDRESS.to_owned(), 1, OutPointMemberMap(std::collections::HashMap::new())).unwrap();
let commit_msg = create_process_return.commit_to_send.unwrap(); let _commit_msg = create_process_return.commit_to_send.unwrap();
let secrets_update = create_process_return.secrets.unwrap(); let secrets_update = create_process_return.secrets.unwrap();
let unconfirmed_secrets = secrets_update.get_all_unconfirmed_secrets(); let unconfirmed_secrets = secrets_update.get_all_unconfirmed_secrets();
@ -183,10 +189,10 @@ fn test_pairing() {
} }
let updated_process = create_process_return.updated_process.unwrap(); let updated_process = create_process_return.updated_process.unwrap();
alice_process_cache.insert(updated_process.commitment_tx, updated_process.current_process); alice_process_cache.insert(updated_process.process_id, updated_process.current_process.clone());
// Alice keeps track of the change she needs to validate // Alice keeps track of the change she needs to validate
let create_process_diffs = updated_process.new_diffs; let create_process_diffs = updated_process.diffs;
let new_state_id = &create_process_diffs.get(0).unwrap().state_id; let new_state_id = &create_process_diffs.get(0).unwrap().state_id;
@ -196,13 +202,13 @@ fn test_pairing() {
// now we create prd update for this new process // now we create prd update for this new process
debug!("Alice creates an update prd to Bob"); debug!("Alice creates an update prd to Bob");
let create_update_return = create_update_message(updated_process.commitment_tx.to_string(), new_state_id.clone()).unwrap(); let create_update_return = create_update_message(updated_process.current_process.clone(), new_state_id.clone(), OutPointMemberMap(std::collections::HashMap::new())).unwrap();
let updated_process = create_update_return.updated_process.unwrap(); let updated_process = create_update_return.updated_process.unwrap();
alice_process_cache.insert(updated_process.commitment_tx, updated_process.current_process); alice_process_cache.insert(updated_process.process_id, updated_process.current_process.clone());
debug!("Alice pairs her device"); debug!("Alice pairs her device");
pair_device(updated_process.commitment_tx.to_string(), vec![helper_get_bob_address()]).unwrap(); pair_device(updated_process.process_id.to_string(), vec![helper_get_bob_address()]).unwrap();
let alice_to_bob_cipher = &create_update_return.ciphers_to_send[0]; let alice_to_bob_cipher = &create_update_return.ciphers_to_send[0];
@ -215,14 +221,11 @@ fn test_pairing() {
set_shared_secrets(serde_json::to_string(&bob_secrets_store).unwrap()).unwrap(); set_shared_secrets(serde_json::to_string(&bob_secrets_store).unwrap()).unwrap();
debug!("Bob receives the update prd"); debug!("Bob receives the update prd");
let bob_parsed_return = parse_cipher(alice_to_bob_cipher.to_owned()).unwrap(); let bob_parsed_return = parse_cipher(alice_to_bob_cipher.to_owned(), OutPointMemberMap(std::collections::HashMap::new())).unwrap();
let updated_process = bob_parsed_return.updated_process.unwrap(); let updated_process = bob_parsed_return.updated_process.unwrap();
let parsed_prd_diffs = updated_process.diffs;
let parsed_prd_diffs = updated_process.new_diffs; bob_process_cache.insert(updated_process.process_id, updated_process.current_process.clone());
// debug!("Bob creates process {} with state {}", updated_process.commitment_tx, new_state_id);
bob_process_cache.insert(updated_process.commitment_tx, updated_process.current_process);
// Bob also keeps track of changes // Bob also keeps track of changes
@ -230,37 +233,26 @@ fn test_pairing() {
debug!("Bob can now fetch the data from storage using the hashes"); debug!("Bob can now fetch the data from storage using the hashes");
// We have to cheat here and let Bob access Alice process cache // We have to cheat here and let Bob access Alice process cache
let process = alice_process_cache.get(&updated_process.commitment_tx).unwrap(); let process = alice_process_cache.get(&updated_process.process_id).unwrap();
// Mise à jour factice sans nouveaux attributs (alignement API)
let state = process.get_state_for_id(&new_state_id).unwrap(); let update_process_res = update_process(process.clone(), Pcd::default(), roles_map.clone(), Pcd::default(), OutPointMemberMap(std::collections::HashMap::new())).unwrap();
let hash2values: Map<String, Value> = bob_diff_cache.iter()
.filter(|diff| diff.state_id == *new_state_id)
.map(|diff| {
let encrypted_value = state.encrypted_pcd.as_object().unwrap().get(&diff.field).unwrap();
(diff.value_commitment.clone(), encrypted_value.clone())
})
.collect();
let update_process_res = update_process_state(updated_process.commitment_tx.to_string(), new_state_id.clone(), serde_json::to_string(&Value::Object(hash2values)).unwrap()).unwrap();
let updated_process = update_process_res.updated_process.unwrap(); let updated_process = update_process_res.updated_process.unwrap();
let parsed_prd_diffs = updated_process.diffs;
let parsed_prd_diffs = updated_process.new_diffs; bob_process_cache.insert(updated_process.process_id, updated_process.current_process.clone());
bob_process_cache.insert(updated_process.commitment_tx, updated_process.current_process);
bob_diff_cache.extend(parsed_prd_diffs); bob_diff_cache.extend(parsed_prd_diffs);
// We can also prune the old diffs from the cache // We can also prune the old diffs from the cache
bob_diff_cache.retain(|diff| diff.new_value != Value::Null); // Prune step removed (structure diff ne porte pas la valeur claire)
// this is only for testing, as we're playing both parts // this is only for testing, as we're playing both parts
let bob_device = dump_device().unwrap(); let bob_device = dump_device().unwrap();
// ======================= Alice // ======================= Alice
reset_device().unwrap(); reset_device().unwrap();
restore_device(alice_device).unwrap(); restore_device(serde_wasm_bindgen::to_value(&alice_device).unwrap()).unwrap();
set_process_cache(serde_json::to_string(&alice_process_cache).unwrap()).unwrap(); set_process_cache(serde_wasm_bindgen::to_value(&alice_process_cache).unwrap()).unwrap();
set_shared_secrets(serde_json::to_string(&alice_secrets_store).unwrap()).unwrap(); set_shared_secrets(serde_json::to_string(&alice_secrets_store).unwrap()).unwrap();
let commitment_outpoint = alice_process_cache.keys().next().unwrap(); let commitment_outpoint = alice_process_cache.keys().next().unwrap();
@ -273,18 +265,18 @@ fn test_pairing() {
} }
// Alice can also sign her response and send it to Bob // Alice can also sign her response and send it to Bob
let validate_state_return = validate_state(commitment_outpoint.to_string(), new_state_id.clone()).unwrap(); let validate_state_return = validate_state(relevant_process.clone(), new_state_id.clone(), OutPointMemberMap(std::collections::HashMap::new())).unwrap();
let updated_process = validate_state_return.updated_process.unwrap(); let updated_process = validate_state_return.updated_process.unwrap();
alice_process_cache.insert(updated_process.commitment_tx, updated_process.current_process); alice_process_cache.insert(updated_process.process_id, updated_process.current_process.clone());
let alice_response = create_response_prd(updated_process.commitment_tx.to_string(), new_state_id.clone()).unwrap(); let alice_response = create_response_prd(updated_process.current_process.clone(), new_state_id.clone(), OutPointMemberMap(std::collections::HashMap::new())).unwrap();
// ======================= Bob // ======================= Bob
reset_device().unwrap(); reset_device().unwrap();
restore_device(bob_device).unwrap(); restore_device(serde_wasm_bindgen::to_value(&bob_device).unwrap()).unwrap();
set_process_cache(serde_json::to_string(&bob_process_cache).unwrap()).unwrap(); set_process_cache(serde_wasm_bindgen::to_value(&bob_process_cache).unwrap()).unwrap();
set_shared_secrets(serde_json::to_string(&bob_secrets_store).unwrap()).unwrap(); set_shared_secrets(serde_json::to_string(&bob_secrets_store).unwrap()).unwrap();
for diff in &bob_diff_cache { for diff in &bob_diff_cache {
@ -296,22 +288,19 @@ fn test_pairing() {
// If user is ok, we can add our own validation token // If user is ok, we can add our own validation token
// Get the whole commitment from the process // Get the whole commitment from the process
let bob_validated_process = validate_state(updated_process.commitment_tx.to_string(), new_state_id.clone()).unwrap(); let bob_validated_process = validate_state(updated_process.current_process.clone(), new_state_id.clone(), OutPointMemberMap(std::collections::HashMap::new())).unwrap();
let updated_process = bob_validated_process.updated_process.unwrap(); let updated_process = bob_validated_process.updated_process.unwrap();
bob_process_cache.insert(updated_process.commitment_tx, updated_process.current_process); bob_process_cache.insert(updated_process.process_id, updated_process.current_process.clone());
let bob_response = create_response_prd(updated_process.commitment_tx.to_string(), new_state_id.clone()).unwrap(); let bob_response = create_response_prd(updated_process.current_process.clone(), new_state_id.clone(), OutPointMemberMap(std::collections::HashMap::new())).unwrap();
let ciphers = bob_response.ciphers_to_send; // We would send it to Alice to let her know we agree let _ciphers = bob_response.ciphers_to_send; // We would send it to Alice to let her know we agree
debug!("Bob pairs device with Alice"); debug!("Bob pairs device with Alice");
let roles: HashMap<String, RoleDefinition> = serde_json::from_value(bob_diff_cache.iter().find(|diff| diff.field == "roles").unwrap().new_value.clone()).unwrap(); pair_device(updated_process.process_id.to_string(), vec![helper_get_bob_address()]).unwrap();
let owner = roles.get("owner").unwrap();
let members_to_pair: Vec<String> = owner.members.iter().flat_map(|m| m.get_addresses()).collect();
pair_device(updated_process.commitment_tx.to_string(), members_to_pair).unwrap();
// We can also check alice response // We can also check alice response
let parsed_alice_response = parse_cipher(alice_response.ciphers_to_send[0].clone()).unwrap(); let _parsed_alice_response = parse_cipher(alice_response.ciphers_to_send[0].clone(), OutPointMemberMap(std::collections::HashMap::new())).unwrap();
} }

View File

@ -5,12 +5,13 @@ use sdk_common::network::NewTxMessage;
use sdk_common::sp_client::bitcoin::consensus::{deserialize, serialize}; use sdk_common::sp_client::bitcoin::consensus::{deserialize, serialize};
use sdk_common::sp_client::bitcoin::hex::{DisplayHex, FromHex}; use sdk_common::sp_client::bitcoin::hex::{DisplayHex, FromHex};
use sdk_common::sp_client::bitcoin::secp256k1::PublicKey; use sdk_common::sp_client::bitcoin::secp256k1::PublicKey;
use sdk_common::sp_client::bitcoin::{OutPoint, ScriptBuf, Transaction}; use sdk_common::sp_client::bitcoin::{OutPoint, Transaction};
use sdk_common::sp_client::silentpayments::utils::receiving::{ use sdk_common::sp_client::silentpayments::utils::receiving::{
calculate_tweak_data, get_pubkey_from_input, calculate_tweak_data, get_pubkey_from_input,
}; };
use sdk_common::sp_client::spclient::{OwnedOutput, SpWallet}; use sdk_common::sp_client::{OwnedOutput, SpClient};
use serde_json::{self, json, Value}; use sdk_common::serialization::OutPointMemberMap;
use serde_json::{self};
// We're using alice and bob for clarity, but it's important to remember that for pairing and login Alice and Bob are the same person // We're using alice and bob for clarity, but it's important to remember that for pairing and login Alice and Bob are the same person
pub const ALICE_START_WALLET: &str = "{\"client\":{\"network\":\"testnet\",\"label\":\"default\",\"scan_sk\":\"e3d8922a41a7cb1a84a90f4334e987bb5ea2df6a1fdf44f789b5302de119f9e2\",\"spend_key\":{\"Secret\":\"93292e5b21042c6cfc742ba30e9d2a1e01609b12d154a1825184ed12c7b9631b\"},\"mnemonic\":null,\"sp_receiver\":{\"version\":0,\"network\":\"Testnet\",\"scan_pubkey\":[2,104,242,105,185,6,124,208,34,44,149,52,163,38,63,221,150,12,198,24,95,143,126,235,37,149,233,88,118,32,86,233,152],\"spend_pubkey\":[3,198,82,196,243,12,59,126,109,143,144,157,128,176,168,94,54,134,232,139,115,102,11,178,128,244,239,251,40,228,67,153,72],\"change_label\":\"ac14a827e2d023b8f7804303a47259366117d99ed932b641d4a8eaf1b82cc992\",\"labels\":[[\"ac14a827e2d023b8f7804303a47259366117d99ed932b641d4a8eaf1b82cc992\",[2,244,223,255,57,50,216,27,133,112,138,69,120,126,85,110,6,242,141,33,136,191,82,164,241,54,179,115,84,161,145,174,154]]]}},\"outputs\":{\"wallet_fingerprint\":[187,119,108,230,171,125,106,11],\"birthday\":1620,\"last_scan\":2146,\"outputs\":{\"9a4a67cc5a40bf882d8b300d91024d7c97024b3b68b2df7745a5b9ea1df1888c:1\":{\"blockheight\":1620,\"tweak\":\"b8b63b3ed97d297b744135cfac2fb4a344c881a77543b71f1fcd16bc67514f26\",\"amount\":3938643,\"script\":\"51205b7b324bb71d411e32f2c61fda5d1db23f5c7d6d416a77fab87c913a1b120be1\",\"label\":\"ac14a827e2d023b8f7804303a47259366117d99ed932b641d4a8eaf1b82cc992\",\"spend_status\":\"Unspent\"}}},\"tx_history\":[]}"; pub const ALICE_START_WALLET: &str = "{\"client\":{\"network\":\"testnet\",\"label\":\"default\",\"scan_sk\":\"e3d8922a41a7cb1a84a90f4334e987bb5ea2df6a1fdf44f789b5302de119f9e2\",\"spend_key\":{\"Secret\":\"93292e5b21042c6cfc742ba30e9d2a1e01609b12d154a1825184ed12c7b9631b\"},\"mnemonic\":null,\"sp_receiver\":{\"version\":0,\"network\":\"Testnet\",\"scan_pubkey\":[2,104,242,105,185,6,124,208,34,44,149,52,163,38,63,221,150,12,198,24,95,143,126,235,37,149,233,88,118,32,86,233,152],\"spend_pubkey\":[3,198,82,196,243,12,59,126,109,143,144,157,128,176,168,94,54,134,232,139,115,102,11,178,128,244,239,251,40,228,67,153,72],\"change_label\":\"ac14a827e2d023b8f7804303a47259366117d99ed932b641d4a8eaf1b82cc992\",\"labels\":[[\"ac14a827e2d023b8f7804303a47259366117d99ed932b641d4a8eaf1b82cc992\",[2,244,223,255,57,50,216,27,133,112,138,69,120,126,85,110,6,242,141,33,136,191,82,164,241,54,179,115,84,161,145,174,154]]]}},\"outputs\":{\"wallet_fingerprint\":[187,119,108,230,171,125,106,11],\"birthday\":1620,\"last_scan\":2146,\"outputs\":{\"9a4a67cc5a40bf882d8b300d91024d7c97024b3b68b2df7745a5b9ea1df1888c:1\":{\"blockheight\":1620,\"tweak\":\"b8b63b3ed97d297b744135cfac2fb4a344c881a77543b71f1fcd16bc67514f26\",\"amount\":3938643,\"script\":\"51205b7b324bb71d411e32f2c61fda5d1db23f5c7d6d416a77fab87c913a1b120be1\",\"label\":\"ac14a827e2d023b8f7804303a47259366117d99ed932b641d4a8eaf1b82cc992\",\"spend_status\":\"Unspent\"}}},\"tx_history\":[]}";
@ -26,13 +27,13 @@ pub const RELAY_ADDRESS: &str = "sprt1qqfmqt0ngq99y8t4ke6uhtm2a2vc2zxvhj7hjrqu59
pub const DEFAULT_NYM: &str = "AliceBob"; pub const DEFAULT_NYM: &str = "AliceBob";
pub fn helper_get_alice_address() -> String { pub fn helper_get_alice_address() -> String {
let wallet: SpWallet = serde_json::from_str(ALICE_START_WALLET).unwrap(); let client: SpClient = serde_json::from_str(ALICE_START_WALLET).unwrap();
wallet.get_client().get_receiving_address() client.get_receiving_address().to_string()
} }
pub fn helper_get_bob_address() -> String { pub fn helper_get_bob_address() -> String {
let wallet: SpWallet = serde_json::from_str(BOB_START_WALLET).unwrap(); let client: SpClient = serde_json::from_str(BOB_START_WALLET).unwrap();
wallet.get_client().get_receiving_address() client.get_receiving_address().to_string()
} }
pub fn helper_get_tweak_data(tx: &str, outpoints: HashMap<OutPoint, OwnedOutput>) -> String { pub fn helper_get_tweak_data(tx: &str, outpoints: HashMap<OutPoint, OwnedOutput>) -> String {
@ -47,7 +48,7 @@ pub fn helper_get_tweak_data(tx: &str, outpoints: HashMap<OutPoint, OwnedOutput>
)); ));
witnesses.push(prevout.witness.clone()); witnesses.push(prevout.witness.clone());
if let Some(output) = outpoints.get(&prevout.previous_output) { if let Some(output) = outpoints.get(&prevout.previous_output) {
spks.push(ScriptBuf::from_hex(&output.script).unwrap()); spks.push(output.script.clone());
} }
} }
let mut input_pubkeys = vec![]; let mut input_pubkeys = vec![];
@ -69,7 +70,7 @@ pub fn helper_parse_transaction(transaction: &str, tweak_data: &str) -> ApiRetur
)) ))
.unwrap(); .unwrap();
// debug!("new_tx_msg: {:?}", new_tx_msg); // debug!("new_tx_msg: {:?}", new_tx_msg);
let result = parse_new_tx(new_tx_msg, 0); let result = parse_new_tx(new_tx_msg, 0, OutPointMemberMap(std::collections::HashMap::new()));
match result { match result {
Ok(m) => m, Ok(m) => m,
Err(e) => panic!("Unexpected error: {}", e.message), Err(e) => panic!("Unexpected error: {}", e.message),