Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ export declare function oracleDelegatedPuzzle(oraclePuzzleHash: Buffer, oracleFe
* @returns {Promise<Buffer>} The signature.
*/
export declare function signCoinSpends(coinSpends: Array<CoinSpend>, privateKeys: Array<Buffer>, forTestnet: boolean): Buffer
export declare function hexSpendBundleToCoinSpends(hex: string): Array<CoinSpend>
/**
* Computes the ID (name) of a coin.
*
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { newLineageProof, newEveProof, Tls, Peer, PeerType, selectCoins, sendXch, morphLauncherId, createServerCoin, mintStore, oracleSpend, addFee, masterPublicKeyToWalletSyntheticKey, masterPublicKeyToFirstPuzzleHash, masterSecretKeyToWalletSyntheticSecretKey, secretKeyToPublicKey, puzzleHashToAddress, addressToPuzzleHash, adminDelegatedPuzzleFromKey, writerDelegatedPuzzleFromKey, oracleDelegatedPuzzle, signCoinSpends, getCoinId, updateStoreMetadata, updateStoreOwnership, meltStore, signMessage, verifySignedMessage, syntheticKeyToPuzzleHash, getCost, getMainnetGenesisChallenge, getTestnet11GenesisChallenge, simulatorNewPuzzle, simulatorNewBlspair, simulatorNewProgram } = nativeBinding
const { newLineageProof, newEveProof, Tls, Peer, PeerType, selectCoins, sendXch, morphLauncherId, createServerCoin, mintStore, oracleSpend, addFee, masterPublicKeyToWalletSyntheticKey, masterPublicKeyToFirstPuzzleHash, masterSecretKeyToWalletSyntheticSecretKey, secretKeyToPublicKey, puzzleHashToAddress, addressToPuzzleHash, adminDelegatedPuzzleFromKey, writerDelegatedPuzzleFromKey, oracleDelegatedPuzzle, signCoinSpends, hexSpendBundleToCoinSpends, getCoinId, updateStoreMetadata, updateStoreOwnership, meltStore, signMessage, verifySignedMessage, syntheticKeyToPuzzleHash, getCost, getMainnetGenesisChallenge, getTestnet11GenesisChallenge, simulatorNewPuzzle, simulatorNewBlspair, simulatorNewProgram } = nativeBinding

module.exports.newLineageProof = newLineageProof
module.exports.newEveProof = newEveProof
Expand All @@ -334,6 +334,7 @@ module.exports.adminDelegatedPuzzleFromKey = adminDelegatedPuzzleFromKey
module.exports.writerDelegatedPuzzleFromKey = writerDelegatedPuzzleFromKey
module.exports.oracleDelegatedPuzzle = oracleDelegatedPuzzle
module.exports.signCoinSpends = signCoinSpends
module.exports.hexSpendBundleToCoinSpends = hexSpendBundleToCoinSpends
module.exports.getCoinId = getCoinId
module.exports.updateStoreMetadata = updateStoreMetadata
module.exports.updateStoreOwnership = updateStoreOwnership
Expand Down
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,17 @@ pub fn sign_coin_spends(
sig.to_js()
}

#[napi]
pub fn hex_spend_bundle_to_coin_spends(hex: String) -> napi::Result<Vec<CoinSpend>> {
let bytes = hex::decode(hex).map_err(js::err)?;
let spend_bundle = RustSpendBundle::from_bytes(&bytes).map_err(js::err)?;
spend_bundle
.coin_spends
.into_iter()
.map(|cs| cs.to_js())
.collect::<Result<Vec<CoinSpend>>>()
}

#[napi]
/// Computes the ID (name) of a coin.
///
Expand Down Expand Up @@ -1615,5 +1626,5 @@ pub fn simulator_new_program(pk: Buffer) -> napi::Result<Buffer> {
let pk = RustPublicKey::from_js(pk)?;
let program =
to_program([AggSigMe::new(pk, b"Hello, world!".to_vec().into())]).map_err(js::err)?;
Ok(program.to_js()?)
program.to_js()
}