Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.
Open
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
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ of the PR were done in a specific way -->
#### All Submissions:

- [ ] I've signed all my commits
- [ ] I followed the [contribution guidelines](https://github.com/MetaMask/bdk-wasm/blob/master/CONTRIBUTING.md)
- [ ] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-wasm/blob/master/CONTRIBUTING.md)
- [ ] I ran `cargo fmt` and `cargo clippy` before committing

#### New Features:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3
- name: Build
run: wasm-pack build --scope metamask --features "esplora"
run: wasm-pack build --scope bitcoindevkit --features "esplora"
- uses: actions/cache@v4
with:
path: |
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Any bug may cost users real money. That being said, we deeply welcome people
contributing for the first time to an open source project or picking up Rust while
contributing. Don't be shy, you'll learn.

The project is currently maintained by the [MetaMask](https://github.com/MetaMask) organization.
The `bdk-wasm` project was originally created and maintained by the [MetaMask](https://github.com/MetaMask) organization.

## Communications Channels

Communication about BDK happens primarily on the [BDK Discord](https://discord.gg/dstn4dQ).

Discussion about code base improvements happens in GitHub [issues](https://github.com/MetaMask/bdk-wasm/issues) and
on [pull requests](https://github.com/MetaMask/bdk-wasm/pulls).
Discussion about code base improvements happens in GitHub [issues](https://github.com/bitcoindevkit/bdk-wasm/issues) and
on [pull requests](https://github.com/bitcoindevkit/bdk-wasm/pulls).

## Contribution Workflow

Expand Down
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
[package]
name = "bitcoindevkit"
version = "0.1.13"
repository = "https://github.com/MetaMask/bdk-wasm"
repository = "https://github.com/bitcoindevkit/bdk-wasm"
description = "A modern, lightweight, descriptor-based wallet library in WebAssembly for browsers and Node"
keywords = [
"bitcoin",
"wallet",
"descriptor",
"psbt",
"wasm",
"bitcoindevkit",
"bdk",
"browser",
"node",
]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</p>

<p>
<a href="https://www.npmjs.com/package/@metamask/bitcoindevkit"><img alt="NPM Package" src="https://img.shields.io/npm/v/@metamask/bitcoindevkit.svg"/></a>
<a href="https://github.com/MetaMask/bdk-wasm/blob/master/LICENSE"><img alt="MIT or Apache-2.0 Licensed" src="https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg"/></a>
<a href="https://www.npmjs.com/package/@bitcoindevkit/bitcoindevkit"><img alt="NPM Package" src="https://img.shields.io/npm/v/@bitcoindevkit/bitcoindevkit.svg"/></a>
<a href="https://github.com/bitcoindevkit/bdk-wasm/blob/master/LICENSE"><img alt="MIT or Apache-2.0 Licensed" src="https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg"/></a>
<a href="https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html"><img alt="Rustc Version 1.73.0+" src="https://img.shields.io/badge/rustc-1.73.0%2B-lightgrey.svg"/></a>
<a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
</p>
Expand Down
12 changes: 6 additions & 6 deletions src/bitcoin/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,18 @@ impl Wallet {
TxBuilder::new(self.0.clone())
}

pub fn calculate_fee(&self, tx: Transaction) -> JsResult<Amount> {
let fee = self.0.borrow().calculate_fee(&tx.into())?;
pub fn calculate_fee(&self, tx: &Transaction) -> JsResult<Amount> {
let fee = self.0.borrow().calculate_fee(tx)?;
Ok(fee.into())
}

pub fn calculate_fee_rate(&self, tx: Transaction) -> JsResult<FeeRate> {
let fee_rate = self.0.borrow().calculate_fee_rate(&tx.into())?;
pub fn calculate_fee_rate(&self, tx: &Transaction) -> JsResult<FeeRate> {
let fee_rate = self.0.borrow().calculate_fee_rate(tx)?;
Ok(fee_rate.into())
}

pub fn sent_and_received(&self, tx: Transaction) -> JsResult<SentAndReceived> {
let (sent, received) = self.0.borrow().sent_and_received(&tx.into());
pub fn sent_and_received(&self, tx: &Transaction) -> JsResult<SentAndReceived> {
let (sent, received) = self.0.borrow().sent_and_received(tx);
Ok(SentAndReceived(sent.into(), received.into()))
}

Expand Down
16 changes: 16 additions & 0 deletions src/types/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ impl AddressInfo {
pub fn address_type(&self) -> Option<AddressType> {
self.0.address_type().map(Into::into)
}

#[wasm_bindgen(js_name = clone)]
pub fn js_clone(&self) -> AddressInfo {
self.clone()
}
}

impl Deref for AddressInfo {
Expand Down Expand Up @@ -101,6 +106,11 @@ impl Address {
pub fn script_pubkey(&self) -> ScriptBuf {
self.0.script_pubkey().into()
}

#[wasm_bindgen(js_name = clone)]
pub fn js_clone(&self) -> Address {
self.clone()
}
}

impl From<BdkAddress> for Address {
Expand Down Expand Up @@ -181,6 +191,11 @@ impl ScriptBuf {
pub fn is_op_return(&self) -> bool {
self.0.is_op_return()
}

#[wasm_bindgen(js_name = clone)]
pub fn js_clone(&self) -> ScriptBuf {
self.clone()
}
}

impl From<BdkScriptBuf> for ScriptBuf {
Expand All @@ -197,6 +212,7 @@ impl From<ScriptBuf> for BdkScriptBuf {

/// The different types of addresses.
#[wasm_bindgen]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum AddressType {
/// Pay to pubkey hash.
P2pkh = "p2pkh",
Expand Down
1 change: 1 addition & 0 deletions src/types/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub struct SentAndReceived(pub Amount, pub Amount);

/// A set of denominations in which amounts can be expressed.
#[wasm_bindgen]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Denomination {
/// BTC
Bitcoin = "BTC",
Expand Down
1 change: 1 addition & 0 deletions src/types/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use super::Amount;

/// Balance, differentiated into various categories.
#[wasm_bindgen]
#[derive(Clone)]
pub struct Balance(BdkBalance);

#[wasm_bindgen]
Expand Down
1 change: 1 addition & 0 deletions src/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use wasm_bindgen::prelude::wasm_bindgen;

/// A reference to a block in the canonical chain.
#[wasm_bindgen]
#[derive(Clone)]
pub struct BlockId(BdkBlockId);

#[wasm_bindgen]
Expand Down
1 change: 1 addition & 0 deletions src/types/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl From<FullScanRequest> for BdkFullScanRequest<KeychainKind> {

/// An update to [`Wallet`].
#[wasm_bindgen]
#[derive(Clone)]
pub struct Update(BdkUpdate);

impl Deref for Update {
Expand Down
1 change: 1 addition & 0 deletions src/types/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use super::BlockId;
/// Checkpoints are cheaply cloneable and are useful to find the agreement point between two sparse
/// block chains.
#[wasm_bindgen]
#[derive(Clone)]
pub struct CheckPoint(BdkCheckPoint);

#[wasm_bindgen]
Expand Down
1 change: 1 addition & 0 deletions src/types/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl From<FeeEstimates> for HashMap<u16, f64> {
/// This is an integer newtype representing fee rate in `sat/kwu`. It provides protection against mixing
/// up the types as well as basic formatting features.
#[wasm_bindgen]
#[derive(Clone, Copy)]
pub struct FeeRate(BdkFeeRate);

impl Deref for FeeRate {
Expand Down
2 changes: 2 additions & 0 deletions src/types/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use crate::types::{OutPoint, ScriptBuf};
/// that it spends and set of scripts that satisfy its spending
/// conditions.
#[wasm_bindgen]
#[derive(Clone)]

pub struct TxIn(BdkTxIn);

impl Deref for TxIn {
Expand Down
2 changes: 1 addition & 1 deletion src/types/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl From<BdkNetwork> for NetworkKind {

/// The cryptocurrency network to act on.
#[wasm_bindgen]
#[derive(Clone, Copy)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Network {
/// Mainnet Bitcoin.
Bitcoin = "bitcoin",
Expand Down
4 changes: 3 additions & 1 deletion src/types/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::Txid;

/// A reference to a transaction output.
#[wasm_bindgen]
#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct OutPoint(BdkOutPoint);

impl Deref for OutPoint {
Expand Down Expand Up @@ -76,6 +76,7 @@ impl From<OutPoint> for BdkOutPoint {
///
/// An output that is not yet spent by an input is called Unspent Transaction Output ("UTXO").
#[wasm_bindgen]
#[derive(Clone)]
pub struct TxOut(BdkTxOut);

impl Deref for TxOut {
Expand Down Expand Up @@ -129,6 +130,7 @@ impl From<TxOut> for BdkTxOut {

/// A reference to a transaction output.
#[wasm_bindgen]
#[derive(Clone)]
pub struct LocalOutput(BdkLocalOutput);

impl Deref for LocalOutput {
Expand Down
6 changes: 6 additions & 0 deletions src/types/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use super::{Address, Amount, FeeRate, Transaction};

/// A Partially Signed Transaction.
#[wasm_bindgen]
#[derive(Clone)]
pub struct Psbt(BdkPsbt);

impl Deref for Psbt {
Expand Down Expand Up @@ -114,6 +115,11 @@ impl Psbt {
pub fn to_json(&self) -> String {
to_string(&self.0).expect("Serialization should not fail")
}

#[wasm_bindgen(js_name = clone)]
pub fn js_clone(&self) -> Psbt {
self.clone()
}
}

impl From<BdkPsbt> for Psbt {
Expand Down
1 change: 1 addition & 0 deletions src/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl From<Transaction> for BdkTransaction {

/// A bitcoin transaction hash/transaction ID.
#[wasm_bindgen]
#[derive(Clone, Copy)]
pub struct Txid(BdkTxid);

impl Deref for Txid {
Expand Down
Loading