Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 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
bf27625
Reveal commit support multiple outputs and signing discovery.
1bananagirl Jan 13, 2025
f3bb0c5
Fix ci
saefstroem Jan 15, 2025
8714f41
Merge branch 'sigma' into sigma-pre
1bananagirl Jan 15, 2025
a3e0452
Merge pull request #143 from aspectron/sigma-pre
1bananagirl Jan 16, 2025
e13cc86
Add utxo context
1bananagirl Jan 22, 2025
17ade0f
Add aggregate compute
1bananagirl Jan 23, 2025
c2ad7e0
Merge pull request #145 from aspectron/utxo-context
1bananagirl Jan 23, 2025
25e0173
Add payment value and addresses
1bananagirl Jan 23, 2025
f5ee61f
Merge pull request #146 from aspectron/utxo-context
1bananagirl Jan 23, 2025
170055a
Merge branch 'master' into sigma
biryukovmaxim Jan 23, 2025
76eb62d
basic
1bananagirl Jan 23, 2025
b8855f3
clippy
surinder83singh Jan 23, 2025
4a6f21a
PskbSign, PskbBroadcast
surinder83singh Jan 23, 2025
73afc42
accounts_pskb_send
surinder83singh Jan 23, 2025
806f539
revealFeeSompi is not optional now
surinder83singh Jan 23, 2025
c784ba0
Merge pull request #147 from aspectron/pskb
aspect Jan 23, 2025
9cee183
addition
1bananagirl Jan 23, 2025
a4ed559
Merge branch 'sigma' into wasm-bundle
surinder83singh Jan 23, 2025
86856b5
Merge branch 'wasm-bundle' of https://github.com/aspectron/rusty-kasp…
surinder83singh Jan 23, 2025
649a8ae
deser test
1bananagirl Jan 23, 2025
ac6df9a
PsktBundle => PSKB
surinder83singh Jan 23, 2025
d731fd6
wip
surinder83singh Jan 24, 2025
90a1334
Update bundle.rs
surinder83singh Jan 24, 2025
94d11c3
Merge pull request #148 from aspectron/wasm-bundle
aspect Jan 24, 2025
1f2e340
bundle wasm unit test patch
1bananagirl Jan 24, 2025
b261cc0
form and unit test with creation of wasm pskt and usage in wasm bundle
1bananagirl Jan 24, 2025
32e653f
PSKB.displayFormat
surinder83singh Jan 25, 2025
a687b00
Merge pull request #149 from aspectron/wasm-bundle
aspect Jan 25, 2025
88ef951
kaspa:utxos
surinder83singh Jan 25, 2025
f776d1e
filters updated
surinder83singh Jan 25, 2025
b9db244
Merge pull request #150 from aspectron/kip12
aspect Jan 25, 2025
f1bbc94
Update pskb.rs
saefstroem Jan 25, 2025
80b19ef
Revert "Update pskb.rs"
saefstroem Jan 25, 2025
93607d8
Prevent value reuse
saefstroem Jan 25, 2025
e46078f
Update pskb.rs
saefstroem Jan 25, 2025
019bdc0
Update pskb.rs
saefstroem Jan 25, 2025
54a5e16
clippy
saefstroem Jan 25, 2025
cb7dcf7
Merge pull request #151 from aspectron/pskb-sign-fix
aspect Jan 25, 2025
6b56d57
signer
1bananagirl Jan 25, 2025
88aec65
Patch PSKT WASM
1bananagirl Jan 25, 2025
31fb075
add input wtih redeem
saefstroem Jan 26, 2025
b28c764
Merge branch 'sigma' into sigma-redeem-script
saefstroem Jan 26, 2025
f85eb81
Update pskt.rs
saefstroem Jan 26, 2025
e8f0572
PSKT input with open data field
1bananagirl Jan 26, 2025
06dcdaf
Input is double hex encoded, therefore decode once
1bananagirl Jan 26, 2025
c76a326
lint
1bananagirl Jan 27, 2025
8cba9a7
Update logging
saefstroem Jan 28, 2025
9b28d5e
add extra logging
saefstroem Jan 28, 2025
8a48d76
Increase verbosity
saefstroem Jan 28, 2025
f16a2d6
increase verbosity
saefstroem Jan 28, 2025
763e02f
Update pskt.rs
saefstroem Jan 28, 2025
2233bfd
Revert "Update pskt.rs"
saefstroem Jan 28, 2025
e90b7e9
Revert " increase verbosity"
saefstroem Jan 28, 2025
261a46b
Revert "Increase verbosity"
saefstroem Jan 28, 2025
b68b5fb
Revert "add extra logging"
saefstroem Jan 28, 2025
4d93cde
Revert "Update logging"
saefstroem Jan 28, 2025
644cd4f
Update mod.rs
saefstroem Jan 28, 2025
64937bd
Merge pull request #153 from aspectron/sigma-redeem-script
aspect Jan 28, 2025
2c2d336
use network params to derive mass
biryukovmaxim Jan 29, 2025
25ced79
remove redundant clones,
biryukovmaxim Jan 29, 2025
aa0718a
payload deserialize bug
surinder83singh Jan 30, 2025
9e1c7c1
keypair account creation api
surinder83singh Jan 30, 2025
e7df0c8
cli changes due to new params
surinder83singh Jan 30, 2025
bb1352b
demo js code for creating account via secret key
surinder83singh Jan 30, 2025
e051e6a
address private keys handling update
surinder83singh Jan 30, 2025
b1fe98a
Merge pull request #155 from aspectron/keypair-account
saefstroem Jan 30, 2025
fba8042
Merge branch 'sigma' into extract_tx
biryukovmaxim Jan 31, 2025
839da81
Merge pull request #154 from biryukovmaxim/extract_tx
saefstroem Jan 31, 2025
482da53
Mass calculation on pskt
saefstroem Jan 31, 2025
7eece40
Update pskt.rs
saefstroem Jan 31, 2025
55c9028
Update pskt.rs
saefstroem Jan 31, 2025
5ba17dc
Update pskt.rs
saefstroem Jan 31, 2025
55d6d3e
update
saefstroem Jan 31, 2025
4c5175d
Merge pull request #157 from aspectron/mass-calc-pskt
saefstroem Feb 1, 2025
bb8dc10
mass
saefstroem Feb 1, 2025
b0702a5
Update pskt.rs
saefstroem Feb 1, 2025
e49f339
Merge pull request #158 from aspectron/mass-estimation-without-p2sh
saefstroem Feb 1, 2025
da95e7f
add doctest
biryukovmaxim Feb 2, 2025
3afd855
Pskb Broadcast
surinder83singh Feb 15, 2025
e87764b
address string trim
surinder83singh Feb 15, 2025
0c7488e
Merge branch 'sigma' into pskb
surinder83singh Feb 15, 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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
10 changes: 7 additions & 3 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 Expand Up @@ -209,13 +214,12 @@ impl Pskb {
for (pskt_index, bundle_inner) in pskb.0.iter().enumerate() {
tprintln!(ctx, "PSKT #{:03} finalized check:", pskt_index + 1);
let pskt: PSKT<Signer> = PSKT::<Signer>::from(bundle_inner.to_owned());

let params = ctx.wallet().network_id()?.into();
let finalizer = pskt.finalizer();

if let Ok(pskt_finalizer) = finalize_pskt_one_or_more_sig_and_redeem_script(finalizer) {
// Verify if extraction is possible.
match pskt_finalizer.extractor() {
Ok(ex) => match ex.extract_tx() {
Ok(ex) => match ex.extract_tx(&params) {
Ok(_) => tprintln!(
ctx,
" Transaction extracted successfully: PSKT is finalized with a valid script signature."
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
3 changes: 2 additions & 1 deletion cli/src/wizards/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::imports::*;
use crate::result::Result;
use kaspa_bip32::{Language, Mnemonic, WordCount};
use kaspa_wallet_core::account::MULTISIG_ACCOUNT_KIND;
use kaspa_wallet_core::storage::keydata::PrvKeyDataVariantKind;
// use kaspa_wallet_core::runtime::wallet::AccountCreateArgsBip32;
// use kaspa_wallet_core::runtime::{PrvKeyDataArgs, PrvKeyDataCreateArgs};
// use kaspa_wallet_core::storage::AccountKind;
Expand Down Expand Up @@ -66,7 +67,7 @@ async fn create_multisig(ctx: &Arc<KaspaCli>, account_name: Option<String>, mnem
for _ in 0..prv_keys_len {
let bip39_mnemonic = Secret::from(Mnemonic::random(mnemonic_phrase_word_count, Language::default())?.phrase());

let prv_key_data_create_args = PrvKeyDataCreateArgs::new(None, None, bip39_mnemonic); // can be optimized with Rc<WalletSecret>
let prv_key_data_create_args = PrvKeyDataCreateArgs::new(None, None, bip39_mnemonic, PrvKeyDataVariantKind::Mnemonic); // can be optimized with Rc<WalletSecret>
let prv_key_data_id = wallet.create_prv_key_data(&wallet_secret, prv_key_data_create_args).await?;

prv_key_data_args.push(PrvKeyDataArgs::new(prv_key_data_id, None));
Expand Down
6 changes: 4 additions & 2 deletions cli/src/wizards/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::cli::KaspaCli;
use crate::imports::*;
use crate::result::Result;
use kaspa_bip32::{Language, Mnemonic, WordCount};
use kaspa_wallet_core::storage::keydata::PrvKeyDataVariantKind;
use kaspa_wallet_core::{
storage::{make_filename, Hint},
wallet::WalletGuard,
Expand Down Expand Up @@ -123,16 +124,17 @@ pub(crate) async fn create(

let prv_key_data_args = if import_with_mnemonic {
let words = crate::wizards::import::prompt_for_mnemonic(&term).await?;
PrvKeyDataCreateArgs::new(None, payment_secret.clone(), Secret::from(words.join(" ")))
PrvKeyDataCreateArgs::new(None, payment_secret.clone(), Secret::from(words.join(" ")), PrvKeyDataVariantKind::Mnemonic)
} else {
PrvKeyDataCreateArgs::new(
None,
payment_secret.clone(),
Secret::from(Mnemonic::random(word_count, Language::default())?.phrase()),
PrvKeyDataVariantKind::Mnemonic,
)
};

let mnemonic_phrase = prv_key_data_args.mnemonic.clone();
let mnemonic_phrase = prv_key_data_args.secret.clone();

let notifier = ctx.notifier().show(Notification::Processing).await;

Expand Down
2 changes: 1 addition & 1 deletion crypto/addresses/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ impl TryCastFromJs for Address {
{
Self::resolve(value, || {
if let Some(string) = value.as_ref().as_string() {
Address::try_from(string)
Address::try_from(string.trim())
} else if let Some(object) = js_sys::Object::try_from(value.as_ref()) {
let prefix: Prefix = object.get_string("prefix")?.as_str().try_into()?;
let payload = object.get_string("payload")?; //.as_str();
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
28 changes: 28 additions & 0 deletions utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ pub mod as_slice;
/// assert_eq!(test_struct, from_json);
/// ```
pub mod serde_bytes;

/// # Examples
/// ## Implement serde::Serialize/serde::Deserialize for the Vec field of the struct
/// ```
/// #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
/// struct MyStructVec {
/// #[serde(with = "kaspa_utils::serde_bytes_optional")]
/// v: Option<Vec<u8>>,
/// }
/// let v = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
/// let len = v.len();
/// let test_struct = MyStructVec { v: Some(v.clone()) };
///
///
/// // Serialize using bincode
/// let encoded = bincode::serialize(&test_struct).unwrap();
/// assert_eq!(encoded, std::iter::once(1).chain(len.to_le_bytes().into_iter()).chain(v.into_iter()).collect::<Vec<_>>());
/// // Deserialize using bincode
/// let decoded: MyStructVec = bincode::deserialize(&encoded).unwrap();
/// assert_eq!(test_struct, decoded);
///
/// let expected_str = r#"{"v":"000102030405060708090a0b0c0d0e0f10111213"}"#;
/// // Serialize using serde_json
/// let json = serde_json::to_string(&test_struct).unwrap();
/// assert_eq!(expected_str, json);
/// // Deserialize using serde_json
/// let from_json: MyStructVec = serde_json::from_str(&json).unwrap();
/// assert_eq!(test_struct, from_json);
pub mod serde_bytes_optional;

/// # Examples
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