0.5.8 • Published 7 months ago
mobit-wallet v0.5.8
Mobit Wallet
Mobit Wallet 是一个轻量级的 TypeScript 库,用于在各种加密货币钱包中进行比特币交易操作。
特性
- 支持多种流行的加密货币钱包
- 提供签署 PSBT 和发送比特币的功能
- 简单易用的 API
- 完全用 TypeScript 编写,提供类型安全
- 专为浏览器环境设计
支持的钱包
- JoyID
- UniSat
- OKX Wallet
安装
使用 npm 安装:
npm install mobit-wallet
使用方法
import { JoyIDWallet, UniSatWallet, OKXWallet } from 'mobit-wallet';
import { DataSource } from '@rgbpp-sdk/btc';
// 创建钱包实例
const joyidWallet = new JoyIDWallet(DataSource.Mempool); // 为 JoyID 指定数据源
const unisatWallet = new UniSatWallet();
const okxWallet = new OKXWallet();
// 签署 PSBT
async function signTransaction(wallet, psbtHex) {
try {
const signedPsbtHex = await wallet.signPsbt(psbtHex);
console.log("Signed PSBT:", signedPsbtHex);
} catch (error) {
console.error("Error signing PSBT:", error);
}
}
// 发送比特币
async function sendBitcoin(wallet, address, amount, feeRate) {
try {
const txid = await wallet.sendBitcoin({ address, amount, feeRate });
console.log("Transaction ID:", txid);
} catch (error) {
console.error("Error sending Bitcoin:", error);
}
}
// 使用示例
signTransaction(joyidWallet, "your_psbt_hex_here");
sendBitcoin(unisatWallet, "recipient_address", 0.001, 1);
注意事项
- 确保在使用前已安装相应的钱包浏览器扩展。
- JoyID 钱包需要指定一个
DataSource
。 - 在生产环境中使用前,请务必进行充分的测试。
- 不同钱包可能有不同的特性和限制,请参考各自的文档。
0.5.8
7 months ago
0.5.4-test.20241217151321
8 months ago
0.5.7
7 months ago
0.5.5-test.20241217163501
8 months ago
0.5.4
8 months ago
0.4.5
8 months ago
0.5.3
8 months ago
0.5.6
7 months ago
0.5.5
8 months ago
0.5.0
8 months ago
0.5.2
8 months ago
0.5.1
8 months ago
0.4.4
11 months ago
0.4.3
11 months ago
0.4.2-test.20240905174958
11 months ago
0.4.2-test.20240905165334
11 months ago
0.4.2-test.20240905161237
11 months ago
0.4.2
11 months ago
0.4.1
11 months ago
0.4.0
11 months ago
0.3.1-test.20240904190610
11 months ago
0.3.1-test.20240904182504
11 months ago
0.3.1-test.20240904174211
11 months ago
0.3.1-test.20240904173906
11 months ago
0.3.1-test.20240901163213
11 months ago
0.3.1-test.20240901153011
11 months ago
0.3.1
11 months ago
0.3.0
11 months ago
0.3.0-test.20240830163136
11 months ago
0.3.0-test.20240830162257
11 months ago
0.3.0-test.20240830162202
11 months ago
0.3.0-test.20240830161314
11 months ago
0.3.0-test.20240830153542
11 months ago
0.3.0-test.20240830151702
11 months ago
0.3.0-test.20240829180905
11 months ago
0.3.0-test.20240829172428
11 months ago
0.3.0-test.20240829170054
11 months ago
0.3.0-test.20240829163549
11 months ago
0.3.0-test.20240829151048
11 months ago
0.3.0-test.20240828191131
11 months ago
0.3.0-test.20240828175122
11 months ago
0.3.0-test.20240828165641
11 months ago
0.2.0
11 months ago
0.1.0
11 months ago