From 1bbf9088c7541ed60f0002b0a4d56e9effe228ac Mon Sep 17 00:00:00 2001 From: surinder singh Date: Thu, 11 Jul 2024 05:15:05 +0530 Subject: [PATCH] Merge branch 'output-addresses' into addresses (#27) --- Cargo.lock | 49 ++++++++++++++++++++++++++++++ Cargo.toml | 1 + core/Cargo.toml | 1 + core/src/egui/extensions.rs | 2 +- core/src/network.rs | 13 ++++++++ core/src/primitives/transaction.rs | 49 ++++++++++++++++++++++++------ 6 files changed, 105 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb246f0..6cec4b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3216,6 +3216,7 @@ dependencies = [ [[package]] name = "kaspa-addresses" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "borsh", "js-sys", @@ -3230,6 +3231,7 @@ dependencies = [ [[package]] name = "kaspa-addressmanager" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "borsh", "igd-next", @@ -3251,6 +3253,7 @@ dependencies = [ [[package]] name = "kaspa-alloc" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "mimalloc", ] @@ -3258,6 +3261,7 @@ dependencies = [ [[package]] name = "kaspa-bip32" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "borsh", "bs58", @@ -3284,6 +3288,7 @@ dependencies = [ [[package]] name = "kaspa-cli" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-trait", "borsh", @@ -3329,6 +3334,7 @@ dependencies = [ [[package]] name = "kaspa-connectionmanager" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "duration-string", "futures-util", @@ -3346,6 +3352,7 @@ dependencies = [ [[package]] name = "kaspa-consensus" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "arc-swap", "async-channel 2.3.1", @@ -3384,6 +3391,7 @@ dependencies = [ [[package]] name = "kaspa-consensus-client" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "ahash", "cfg-if 1.0.0", @@ -3412,6 +3420,7 @@ dependencies = [ [[package]] name = "kaspa-consensus-core" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-trait", "borsh", @@ -3446,6 +3455,7 @@ dependencies = [ [[package]] name = "kaspa-consensus-notify" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "cfg-if 1.0.0", @@ -3465,6 +3475,7 @@ dependencies = [ [[package]] name = "kaspa-consensus-wasm" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "cfg-if 1.0.0", "faster-hex 0.6.1", @@ -3489,6 +3500,7 @@ dependencies = [ [[package]] name = "kaspa-consensusmanager" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "duration-string", "futures", @@ -3507,6 +3519,7 @@ dependencies = [ [[package]] name = "kaspa-core" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "cfg-if 1.0.0", "ctrlc", @@ -3525,6 +3538,7 @@ dependencies = [ [[package]] name = "kaspa-daemon" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-trait", "borsh", @@ -3547,6 +3561,7 @@ dependencies = [ [[package]] name = "kaspa-database" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "bincode", "enum-primitive-derive", @@ -3569,6 +3584,7 @@ dependencies = [ [[package]] name = "kaspa-grpc-client" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "async-stream", @@ -3600,6 +3616,7 @@ dependencies = [ [[package]] name = "kaspa-grpc-core" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "async-stream", @@ -3629,6 +3646,7 @@ dependencies = [ [[package]] name = "kaspa-grpc-server" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "async-stream", @@ -3663,6 +3681,7 @@ dependencies = [ [[package]] name = "kaspa-hashes" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "blake2b_simd", "borsh", @@ -3681,6 +3700,7 @@ dependencies = [ [[package]] name = "kaspa-index-core" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "async-trait", @@ -3700,6 +3720,7 @@ dependencies = [ [[package]] name = "kaspa-index-processor" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "async-trait", @@ -3725,6 +3746,7 @@ dependencies = [ [[package]] name = "kaspa-math" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "borsh", "faster-hex 0.6.1", @@ -3744,6 +3766,7 @@ dependencies = [ [[package]] name = "kaspa-merkle" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "kaspa-hashes", ] @@ -3751,6 +3774,7 @@ dependencies = [ [[package]] name = "kaspa-metrics-core" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-trait", "borsh", @@ -3767,6 +3791,7 @@ dependencies = [ [[package]] name = "kaspa-mining" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "futures-util", "itertools 0.11.0", @@ -3791,6 +3816,7 @@ dependencies = [ [[package]] name = "kaspa-mining-errors" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "kaspa-consensus-core", "thiserror", @@ -3799,6 +3825,7 @@ dependencies = [ [[package]] name = "kaspa-muhash" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "kaspa-hashes", "kaspa-math", @@ -3879,6 +3906,7 @@ dependencies = [ "kaspa-notify", "kaspa-rpc-core", "kaspa-rpc-service", + "kaspa-txscript", "kaspa-utils", "kaspa-wallet-core", "kaspa-wallet-keys", @@ -3938,6 +3966,7 @@ dependencies = [ [[package]] name = "kaspa-notify" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "async-trait", @@ -3969,6 +3998,7 @@ dependencies = [ [[package]] name = "kaspa-p2p-flows" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-trait", "chrono", @@ -4000,6 +4030,7 @@ dependencies = [ [[package]] name = "kaspa-p2p-lib" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "borsh", "ctrlc", @@ -4030,6 +4061,7 @@ dependencies = [ [[package]] name = "kaspa-perf-monitor" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "kaspa-core", "log", @@ -4042,6 +4074,7 @@ dependencies = [ [[package]] name = "kaspa-pow" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "js-sys", "kaspa-consensus-client", @@ -4057,6 +4090,7 @@ dependencies = [ [[package]] name = "kaspa-rpc-core" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "async-trait", @@ -4098,6 +4132,7 @@ dependencies = [ [[package]] name = "kaspa-rpc-macros" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "convert_case 0.6.0", "proc-macro-error", @@ -4110,6 +4145,7 @@ dependencies = [ [[package]] name = "kaspa-rpc-service" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-trait", "kaspa-addresses", @@ -4139,6 +4175,7 @@ dependencies = [ [[package]] name = "kaspa-txscript" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "blake2b_simd", "borsh", @@ -4168,6 +4205,7 @@ dependencies = [ [[package]] name = "kaspa-txscript-errors" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "secp256k1", "thiserror", @@ -4176,6 +4214,7 @@ dependencies = [ [[package]] name = "kaspa-utils" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "borsh", @@ -4200,6 +4239,7 @@ dependencies = [ [[package]] name = "kaspa-utils-tower" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "cfg-if 1.0.0", "futures", @@ -4214,6 +4254,7 @@ dependencies = [ [[package]] name = "kaspa-utxoindex" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "futures", "kaspa-consensus-core", @@ -4233,6 +4274,7 @@ dependencies = [ [[package]] name = "kaspa-wallet-core" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "aes", "ahash", @@ -4311,6 +4353,7 @@ dependencies = [ [[package]] name = "kaspa-wallet-keys" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-trait", "borsh", @@ -4343,6 +4386,7 @@ dependencies = [ [[package]] name = "kaspa-wallet-macros" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "convert_case 0.5.0", "proc-macro-error", @@ -4356,6 +4400,7 @@ dependencies = [ [[package]] name = "kaspa-wasm-core" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "faster-hex 0.6.1", "js-sys", @@ -4365,6 +4410,7 @@ dependencies = [ [[package]] name = "kaspa-wrpc-client" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-std", "async-trait", @@ -4400,6 +4446,7 @@ dependencies = [ [[package]] name = "kaspa-wrpc-server" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-trait", "borsh", @@ -4428,6 +4475,7 @@ dependencies = [ [[package]] name = "kaspa-wrpc-wasm" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "ahash", "async-std", @@ -4457,6 +4505,7 @@ dependencies = [ [[package]] name = "kaspad" version = "0.14.1" +source = "git+https://github.com/aspectron/rusty-kaspa.git?branch=omega#1d37b63c95c2fee25789657e4a3fc0f12f425c29" dependencies = [ "async-channel 2.3.1", "clap 4.5.9", diff --git a/Cargo.toml b/Cargo.toml index 83cbde9..4afc8e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,6 +125,7 @@ kaspa-wallet-core = { git = "https://github.com/aspectron/rusty-kaspa.git", bran kaspa-wallet-keys = { git = "https://github.com/aspectron/rusty-kaspa.git", branch = "omega" } kaspa-wrpc-client = { git = "https://github.com/aspectron/rusty-kaspa.git", branch = "omega" } kaspa-wrpc-server = { git = "https://github.com/aspectron/rusty-kaspa.git", branch = "omega" } +kaspa-txscript = { git = "https://github.com/aspectron/rusty-kaspa.git", branch = "omega" } kaspad = { git = "https://github.com/aspectron/rusty-kaspa.git", branch = "omega" } # _________________________________________________________ diff --git a/core/Cargo.toml b/core/Cargo.toml index 6de2916..89e0749 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -37,6 +37,7 @@ kaspa-utils.workspace = true kaspa-wallet-core.workspace = true kaspa-wallet-keys.workspace = true kaspa-wrpc-client.workspace = true +kaspa-txscript.workspace = true workflow-core.workspace = true workflow-i18n.workspace = true diff --git a/core/src/egui/extensions.rs b/core/src/egui/extensions.rs index 1c79133..e1c9f0b 100644 --- a/core/src/egui/extensions.rs +++ b/core/src/egui/extensions.rs @@ -147,7 +147,7 @@ impl LayoutJobBuilder { let job = LayoutJob { wrap: TextWrapping { max_width: width, - max_rows: 1, + max_rows: 4, break_anywhere: true, overflow_character: Some('…'), }, diff --git a/core/src/network.rs b/core/src/network.rs index 57a7c4f..80fdbfe 100644 --- a/core/src/network.rs +++ b/core/src/network.rs @@ -1,4 +1,5 @@ use crate::imports::*; +use kaspa_addresses::Prefix as AddressPrefix; use kaspa_consensus_core::config::params::Params; use kaspa_wallet_core::utxo::NetworkParams; @@ -70,6 +71,18 @@ impl From for NetworkId { } } +impl From<&Network> for AddressPrefix { + fn from(network: &Network) -> Self { + NetworkType::from(network).into() + } +} + +impl From for AddressPrefix { + fn from(network: Network) -> Self { + NetworkType::from(network).into() + } +} + impl From<&Network> for NetworkId { fn from(network: &Network) -> Self { match network { diff --git a/core/src/primitives/transaction.rs b/core/src/primitives/transaction.rs index 4794d3d..90624be 100644 --- a/core/src/primitives/transaction.rs +++ b/core/src/primitives/transaction.rs @@ -1,6 +1,7 @@ use crate::imports::*; use egui_phosphor::light::*; use kaspa_consensus_core::tx::{TransactionInput, TransactionOutpoint, TransactionOutput}; +use kaspa_txscript::standard::extract_script_pub_key_address; use kaspa_wallet_core::storage::{ transaction::{TransactionData, UtxoRecord}, TransactionKind, @@ -512,22 +513,52 @@ impl Transaction { ) .label(ui); + let address_prefix: kaspa_addresses::Prefix = network.into(); + for output in transaction.outputs.iter() { let TransactionOutput { value, - script_public_key, + .. + //script_public_key, } = output; ljb(&content) - .text( - &format!( - " {} {}", - ps2k(*value), - script_public_key.script_as_hex() - ), - default_color, - ) + .text(&format!(" {}", ps2k(*value)), default_color) .label(ui); + + // ljb(&content) + // .text(&format!(" {}", script_public_key.script_as_hex()), default_color) + // .label(ui); + + let address_info = extract_script_pub_key_address( + &output.script_public_key, + address_prefix, + ); + match address_info { + Ok(address) => { + let address = address.to_string(); + ljb(&content).padded(2, "", default_color).hyperlink( + ui, + &address, + &format!("{explorer}/addresses/{address}"), + default_color, + ); + } + Err(err) => { + log_info!("scriptpubkey to address error: {:?}", err) + } + } + + // ljb(&content) + // .text( + // &format!( + // " {} {}", + // ps2k(*value), + // script_public_key.script_as_hex() + // ), + // default_color, + // ) + // .label(ui); } }); }