Skip to content

Commit 09e18cf

Browse files
committed
Hex spend bundle to coin spends
1 parent fb5783f commit 09e18cf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,17 @@ pub fn sign_coin_spends(
13681368
sig.to_js()
13691369
}
13701370

1371+
#[napi]
1372+
pub fn hex_spend_bundle_to_coin_spends(hex: String) -> napi::Result<Vec<CoinSpend>> {
1373+
let bytes = hex::decode(hex).map_err(js::err)?;
1374+
let spend_bundle = RustSpendBundle::from_bytes(&bytes).map_err(js::err)?;
1375+
spend_bundle
1376+
.coin_spends
1377+
.into_iter()
1378+
.map(|cs| cs.to_js())
1379+
.collect::<Result<Vec<CoinSpend>>>()
1380+
}
1381+
13711382
#[napi]
13721383
/// Computes the ID (name) of a coin.
13731384
///
@@ -1615,5 +1626,5 @@ pub fn simulator_new_program(pk: Buffer) -> napi::Result<Buffer> {
16151626
let pk = RustPublicKey::from_js(pk)?;
16161627
let program =
16171628
to_program([AggSigMe::new(pk, b"Hello, world!".to_vec().into())]).map_err(js::err)?;
1618-
Ok(program.to_js()?)
1629+
program.to_js()
16191630
}

0 commit comments

Comments
 (0)