Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sigmav254 #141

Merged
merged 58 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
d004d89
pending tx (WIP)
aspect Sep 2, 2024
8ccf8a4
Merge branch 'dev' of https://github.com/kaspanet/rusty-kaspa into rb…
aspect Sep 2, 2024
db21255
wip
aspect Sep 5, 2024
8d06a34
WIP fee_rate
aspect Sep 9, 2024
0ccad51
WIP
aspect Sep 9, 2024
db1ec4f
Merge branch 'dev' of https://github.com/kaspanet/rusty-kaspa into rb…
aspect Sep 9, 2024
bc254da
fee rate propagation
aspect Sep 9, 2024
e8cbe86
propagate fee_rate in generator tests
aspect Sep 9, 2024
c9e9247
WIP
aspect Sep 9, 2024
0fff1ef
change fee_rate combining to use max()
aspect Sep 9, 2024
be33081
update max() handling
aspect Sep 9, 2024
bf434fd
Merge branch 'dev' of https://github.com/kaspanet/rusty-kaspa into rb…
aspect Sep 10, 2024
4cf3d52
Generator summary aggregate_mass
aspect Sep 10, 2024
9314168
Merge branch 'dev' of https://github.com/kaspanet/rusty-kaspa into rb…
aspect Sep 10, 2024
b910457
generator summary number_of_stages
aspect Sep 11, 2024
d82b2c2
Merge branch 'master' of https://github.com/kaspanet/rusty-kaspa into…
aspect Sep 11, 2024
458354b
WIP
aspect Sep 12, 2024
bc583a5
Merge branch 'kaspanet:master' into rbf-utils
KaffinPX Sep 13, 2024
29e32c9
Merge branch 'gamma-dev' of github.com:aspectron/rusty-kaspa into rbf…
aspect Sep 13, 2024
4a1e5ef
calculateStorageMass
aspect Sep 26, 2024
5993abb
Merge branch 'gamma-dev' of github.com:aspectron/rusty-kaspa into gen…
aspect Sep 26, 2024
c8d829c
cleanup
aspect Sep 26, 2024
aaf66d4
cleanup tests
aspect Sep 26, 2024
350bd39
fix wasm imports
aspect Sep 27, 2024
8d47393
Merge branch 'master' of github.com:aspectron/rusty-kaspa into gamma-dev
aspect Sep 28, 2024
53c4bbe
update wrpc/client/Cargo.toml to include Resolvers.toml config file
aspect Sep 28, 2024
65a6967
Merge branch 'master' into gamma-dev
surinder83singh Oct 9, 2024
8147bdd
accounts_import api impl (#107)
surinder83singh Oct 10, 2024
158d4be
add missing setNetworkId to wasm Wallet()
aspect Oct 20, 2024
79cebc0
rust 1.82 updates
aspect Oct 20, 2024
c54e83d
Merge branch 'kaspanet:master' into gamma-dev
KaffinPX Oct 25, 2024
8112be1
Merge branch 'master' into gamma-dev
surinder83singh Dec 9, 2024
36d3ea2
Merge branch 'gamma' into gamma-dev
surinder83singh Dec 9, 2024
ef92116
Merge branch 'master' into gamma-dev
surinder83singh Dec 9, 2024
53fd7f8
Remove KIP9 Alpha version references
surinder83singh Dec 9, 2024
e0dc85f
Add support for `update_address_indexes` parameter in `derivation_sca…
surinder83singh Dec 9, 2024
7fa484e
wallet example update
surinder83singh Dec 18, 2024
03100ae
Update binding.rs
surinder83singh Dec 18, 2024
3130a69
FeeRate estimation API and FeeRate poller API for Wallet (#130)
aspect Dec 25, 2024
0dd2997
list of account addresses in account descriptor (#131)
aspect Dec 26, 2024
afb3ffa
Wallet API - WalletList event
aspect Dec 26, 2024
697ce3e
Wallet API support for atomic commit reveal transaction.
1bananagirl Dec 27, 2024
659ea81
Merge pull request #132 from aspectron/wallet-enhancements-merge
1bananagirl Dec 27, 2024
ca1a26b
Switch API wallet commit reveal param vec of fees to one u64.
1bananagirl Dec 28, 2024
8931411
Linting.
1bananagirl Dec 28, 2024
ee8dc51
Adapt doc on changes.
1bananagirl Dec 28, 2024
d654803
Merge pull request #133 from aspectron/wallet-enhancements-fees-patch
1bananagirl Dec 28, 2024
5394020
fix extend() error on ScriptBuilder replacing it with script_mut() ac…
aspect Dec 28, 2024
1812a98
enum camelcase
surinder83singh Dec 31, 2024
2f71e61
missing ts types
surinder83singh Jan 1, 2025
3535e6a
camelCase on connect event
surinder83singh Jan 1, 2025
b8d09db
Merge pull request #134 from aspectron/ts-types
saefstroem Jan 1, 2025
1b1a3e6
skipping load from db if already active account (#137)
surinder83singh Jan 9, 2025
ee15939
skip account start if already active
surinder83singh Jan 9, 2025
c6b2764
Merge pull request #139 from aspectron/account_activate
aspect Jan 9, 2025
8ff010b
maturity progress helper functions
surinder83singh Jan 10, 2025
9873cee
Merge pull request #140 from aspectron/maturity_progress
aspect Jan 10, 2025
363c23d
clippy
surinder83singh Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,14 @@ impl KaspaCli {

if let Ok(msg) = msg {
match *msg {
Events::WalletList { .. } => {},
Events::WalletPing => {
// log_info!("Kaspa NG - received wallet ping");
},
Events::Metrics { network_id : _, metrics : _ } => {
// log_info!("Kaspa NG - received metrics event {metrics:?}")
}
Events::FeeRate { .. } => {},
Events::Error { message } => { terrorln!(this,"{message}"); },
Events::UtxoProcStart => {},
Events::UtxoProcStop => {},
Expand Down
8 changes: 6 additions & 2 deletions cli/src/modules/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ impl Account {
count = count.max(1);

let sweep = action.eq("sweep");

self.derivation_scan(&ctx, start, count, window, sweep).await?;
// TODO fee_rate
let fee_rate = None;
self.derivation_scan(&ctx, start, count, window, sweep, fee_rate).await?;
}
v => {
tprintln!(ctx, "unknown command: '{v}'\r\n");
Expand Down Expand Up @@ -276,6 +277,7 @@ impl Account {
count: usize,
window: usize,
sweep: bool,
fee_rate: Option<f64>,
) -> Result<()> {
let account = ctx.account().await?;
let (wallet_secret, payment_secret) = ctx.ask_wallet_secret(Some(&account)).await?;
Expand All @@ -293,7 +295,9 @@ impl Account {
start + count,
window,
sweep,
fee_rate,
&abortable,
true,
Some(Arc::new(move |processed: usize, _, balance, txid| {
if let Some(txid) = txid {
tprintln!(
Expand Down
5 changes: 4 additions & 1 deletion cli/src/modules/estimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ impl Estimate {
}

let amount_sompi = try_parse_required_nonzero_kaspa_as_sompi_u64(argv.first())?;
// TODO fee_rate
let fee_rate = None;
let priority_fee_sompi = try_parse_optional_kaspa_as_sompi_i64(argv.get(1))?.unwrap_or(0);
let abortable = Abortable::default();

// just use any address for an estimate (change address)
let change_address = account.change_address()?;
let destination = PaymentDestination::PaymentOutputs(PaymentOutputs::from((change_address.clone(), amount_sompi)));
let estimate = account.estimate(destination, priority_fee_sompi.into(), None, &abortable).await?;
// TODO fee_rate
let estimate = account.estimate(destination, fee_rate, priority_fee_sompi.into(), None, &abortable).await?;

tprintln!(ctx, "Estimate - {estimate}");

Expand Down
5 changes: 5 additions & 0 deletions cli/src/modules/pskb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ impl Pskb {
let signer = account
.pskb_from_send_generator(
outputs.into(),
// fee_rate
None,
priority_fee_sompi.into(),
None,
wallet_secret.clone(),
Expand Down Expand Up @@ -89,12 +91,15 @@ impl Pskb {
"lock" => {
let amount_sompi = try_parse_required_nonzero_kaspa_as_sompi_u64(argv.first())?;
let outputs = PaymentOutputs::from((script_p2sh, amount_sompi));
// TODO fee_rate
let fee_rate = None;
let priority_fee_sompi = try_parse_optional_kaspa_as_sompi_i64(argv.get(1))?.unwrap_or(0);
let abortable = Abortable::default();

let signer = account
.pskb_from_send_generator(
outputs.into(),
fee_rate,
priority_fee_sompi.into(),
None,
wallet_secret.clone(),
Expand Down
3 changes: 3 additions & 0 deletions cli/src/modules/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ impl Send {

let address = Address::try_from(argv.first().unwrap().as_str())?;
let amount_sompi = try_parse_required_nonzero_kaspa_as_sompi_u64(argv.get(1))?;
// TODO fee_rate
let fee_rate = None;
let priority_fee_sompi = try_parse_optional_kaspa_as_sompi_i64(argv.get(2))?.unwrap_or(0);
let outputs = PaymentOutputs::from((address.clone(), amount_sompi));
let abortable = Abortable::default();
Expand All @@ -27,6 +29,7 @@ impl Send {
let (summary, _ids) = account
.send(
outputs.into(),
fee_rate,
priority_fee_sompi.into(),
None,
wallet_secret,
Expand Down
3 changes: 3 additions & 0 deletions cli/src/modules/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ impl Sweep {

let account = ctx.wallet().account()?;
let (wallet_secret, payment_secret) = ctx.ask_wallet_secret(Some(&account)).await?;
// TODO fee_rate
let fee_rate = None;
let abortable = Abortable::default();
// let ctx_ = ctx.clone();
let (summary, _ids) = account
.sweep(
wallet_secret,
payment_secret,
fee_rate,
&abortable,
Some(Arc::new(move |_ptx| {
// tprintln!(ctx_, "Sending transaction: {}", ptx.id());
Expand Down
3 changes: 3 additions & 0 deletions cli/src/modules/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ impl Transfer {
return Err("Cannot transfer to the same account".into());
}
let amount_sompi = try_parse_required_nonzero_kaspa_as_sompi_u64(argv.get(1))?;
// TODO fee_rate
let fee_rate = None;
let priority_fee_sompi = try_parse_optional_kaspa_as_sompi_i64(argv.get(2))?.unwrap_or(0);
let target_address = target_account.receive_address()?;
let (wallet_secret, payment_secret) = ctx.ask_wallet_secret(Some(&account)).await?;
Expand All @@ -32,6 +34,7 @@ impl Transfer {
let (summary, _ids) = account
.send(
outputs.into(),
fee_rate,
priority_fee_sompi.into(),
None,
wallet_secret,
Expand Down
2 changes: 1 addition & 1 deletion crypto/txscript/src/opcodes/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ macro_rules! opcode_list {
}
}
else if let Some(Ok(value)) = token.strip_prefix("0x").and_then(|trimmed| Some(hex::decode(trimmed))) {
builder.extend(&value);
builder.script_mut().extend(&value);
}
else if token.len() >= 2 && token.chars().nth(0) == Some('\'') && token.chars().last() == Some('\'') {
builder.add_data(token[1..token.len()-1].as_bytes())?;
Expand Down
10 changes: 7 additions & 3 deletions crypto/txscript/src/script_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ impl ScriptBuilder {
&self.script
}

#[cfg(any(test, target_arch = "wasm32"))]
pub fn extend(&mut self, data: &[u8]) {
self.script.extend(data);
pub fn script_mut(&mut self) -> &mut Vec<u8> {
&mut self.script
}

// #[cfg(any(test, target_arch = "wasm32"))]
// pub fn extend(&mut self, data: &[u8]) {
// self.script.extend(data);
// }

pub fn drain(&mut self) -> Vec<u8> {
// Note that the internal script, when taken, is replaced by
// vector with no predefined capacity because the script
Expand Down
2 changes: 1 addition & 1 deletion crypto/txscript/src/wasm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl ScriptBuilder {
pub fn from_script(script: BinaryT) -> Result<ScriptBuilder> {
let builder = ScriptBuilder::default();
let script = script.try_as_vec_u8()?;
builder.inner_mut().extend(&script);
builder.inner_mut().script_mut().extend(&script);

Ok(builder)
}
Expand Down
9 changes: 8 additions & 1 deletion rpc/wrpc/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ rust-version.workspace = true
version.workspace = true
edition.workspace = true
authors.workspace = true
include.workspace = true
license.workspace = true
repository.workspace = true
include = [
"src/**/*.rs",
"benches/**/*.rs",
"build.rs",
"Cargo.toml",
"Cargo.lock",
"Resolvers.toml",
]

[features]
wasm32-sdk = ["kaspa-consensus-wasm/wasm32-sdk","kaspa-rpc-core/wasm32-sdk","workflow-rpc/wasm32-sdk"]
Expand Down
4 changes: 2 additions & 2 deletions rpc/wrpc/wasm/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ impl RpcClient {
/// Set the network id for the RPC client.
/// This setting will take effect on the next connection.
#[wasm_bindgen(js_name = setNetworkId)]
pub fn set_network_id(&self, network_id: &NetworkId) -> Result<()> {
self.inner.client.set_network_id(network_id)?;
pub fn set_network_id(&self, network_id: &NetworkIdT) -> Result<()> {
self.inner.client.set_network_id(&network_id.try_into_owned()?)?;
Ok(())
}

Expand Down
5 changes: 5 additions & 0 deletions wallet/bip32/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ mod prefix;
mod result;
pub mod types;

pub mod wasm {
//! WASM bindings for the `bip32` module.
pub use crate::mnemonic::{Language, Mnemonic, WordCount};
}

pub use address_type::AddressType;
pub use attrs::ExtendedKeyAttrs;
pub use child_number::ChildNumber;
Expand Down
7 changes: 7 additions & 0 deletions wallet/core/src/account/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct AccountDescriptor {
pub prv_key_data_ids: AssocPrvKeyDataIds,
pub receive_address: Option<Address>,
pub change_address: Option<Address>,
pub addresses: Option<Vec<Address>>,

pub properties: BTreeMap<AccountDescriptorProperty, AccountDescriptorValue>,
}
Expand All @@ -39,6 +40,7 @@ impl AccountDescriptor {
prv_key_data_ids: AssocPrvKeyDataIds,
receive_address: Option<Address>,
change_address: Option<Address>,
addresses: Option<Vec<Address>>,
) -> Self {
Self {
kind,
Expand All @@ -48,6 +50,7 @@ impl AccountDescriptor {
prv_key_data_ids,
receive_address,
change_address,
addresses,
properties: BTreeMap::default(),
}
}
Expand Down Expand Up @@ -241,6 +244,7 @@ declare! {
accountName? : string,
receiveAddress? : Address,
changeAddress? : Address,
addresses? : Address[],
prvKeyDataIds : HexString[],
// balance? : Balance,
[key: string]: any
Expand All @@ -259,6 +263,9 @@ impl TryFrom<AccountDescriptor> for IAccountDescriptor {
object.set("receiveAddress", &descriptor.receive_address.into())?;
object.set("changeAddress", &descriptor.change_address.into())?;

let addresses = js_sys::Array::from_iter(descriptor.addresses.into_iter().map(JsValue::from));
object.set("addresses", &addresses)?;

let prv_key_data_ids = js_sys::Array::from_iter(descriptor.prv_key_data_ids.into_iter().map(JsValue::from));
object.set("prvKeyDataIds", &prv_key_data_ids)?;

Expand Down
Loading
Loading