Skip to content

Commit

Permalink
Add has puzzle hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Feb 19, 2024
1 parent 9585b76 commit 42d317b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class Peer {
export class Wallet {
static initialSync(peer: Peer, mnemonic: string, aggSigMe: Uint8Array): Promise<Wallet>
derivationIndex(): Promise<number>
hasPuzzleHash(puzzleHash: Uint8Array): Promise<boolean>
createServerCoin(launcherId: Uint8Array, amount: number, fee: number, urls: Array<string>): Promise<boolean>
deleteServerCoins(coins: Array<Coin>, fee: number): Promise<boolean>
}
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use chia_client::Peer as RustPeer;
use chia_protocol::{Coin as RustCoin, NodeType, SpendBundle};
use chia_wallet_sdk::{
connect_peer, create_tls_connector, incremental_sync, load_ssl_cert, sign_spend_bundle,
MemoryCoinStore, PublicKeyStore, SimpleDerivationStore, SyncConfig,
DerivationStore, MemoryCoinStore, PublicKeyStore, SimpleDerivationStore, SyncConfig,
};
use clvmr::Allocator;
use napi::{bindgen_prelude::Uint8Array, Error, Result};
Expand Down Expand Up @@ -130,6 +130,16 @@ impl Wallet {
self.derivation_store.count().await
}

#[napi]
pub async fn has_puzzle_hash(&self, puzzle_hash: Uint8Array) -> Result<bool> {
let puzzle_hash = bytes32(puzzle_hash)?;
Ok(self
.derivation_store
.index_of_ph(puzzle_hash)
.await
.is_some())
}

#[napi]
pub async fn create_server_coin(
&self,
Expand Down

0 comments on commit 42d317b

Please sign in to comment.