@btc-vision/wallet-sdk 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/lib/address/index.d.ts +36 -0
  2. package/lib/bitcoin-core.d.ts +5 -0
  3. package/lib/constants.d.ts +1 -0
  4. package/lib/error.d.ts +20 -0
  5. package/lib/index.d.ts +14 -0
  6. package/lib/keyring/hd-keyring.d.ts +50 -0
  7. package/lib/keyring/index.d.ts +4 -0
  8. package/lib/keyring/interfaces/SimpleKeyringOptions.d.ts +52 -0
  9. package/lib/keyring/keystone-keyring.d.ts +82 -0
  10. package/lib/keyring/simple-keyring.d.ts +11 -0
  11. package/lib/message/bip322-simple.d.ts +19 -0
  12. package/lib/message/deterministic-ecdsa.d.ts +2 -0
  13. package/lib/message/ecdsa.d.ts +3 -0
  14. package/lib/message/index.d.ts +3 -0
  15. package/lib/network/index.d.ts +14 -0
  16. package/lib/runes/index.d.ts +1 -0
  17. package/lib/runes/rund_id.d.ts +11 -0
  18. package/lib/runes/varint.d.ts +14 -0
  19. package/lib/transaction/index.d.ts +3 -0
  20. package/lib/transaction/inscription-utxo.d.ts +33 -0
  21. package/lib/transaction/transaction.d.ts +51 -0
  22. package/lib/transaction/utxo.d.ts +35 -0
  23. package/lib/tx-helpers/index.d.ts +8 -0
  24. package/lib/tx-helpers/send-atomicals-ft.d.ts +16 -0
  25. package/lib/tx-helpers/send-atomicals-nft.d.ts +14 -0
  26. package/lib/tx-helpers/send-btc.d.ts +28 -0
  27. package/lib/tx-helpers/send-inscription.d.ts +16 -0
  28. package/lib/tx-helpers/send-inscriptions.d.ts +14 -0
  29. package/lib/tx-helpers/send-runes.d.ts +19 -0
  30. package/lib/tx-helpers/split-inscription-utxo.d.ts +15 -0
  31. package/lib/types.d.ts +59 -0
  32. package/lib/utils.d.ts +23 -0
  33. package/lib/wallet/abstract-wallet.d.ts +6 -0
  34. package/lib/wallet/estimate-wallet.d.ts +23 -0
  35. package/lib/wallet/index.d.ts +3 -0
  36. package/lib/wallet/local-wallet.d.ts +23 -0
  37. package/package.json +1 -1
@@ -0,0 +1,36 @@
1
+ import * as bitcoin from '@btc-vision/bitcoin';
2
+ import { NetworkType } from '../network';
3
+ import { AddressType } from '../types';
4
+ /**
5
+ * Convert public key to bitcoin payment object.
6
+ */
7
+ export declare function publicKeyToPayment(publicKey: string, type: AddressType, networkType: NetworkType): bitcoin.P2PKHPayment | bitcoin.P2WPKHPayment | bitcoin.P2TRPayment | bitcoin.P2SHPayment | null | undefined;
8
+ /**
9
+ * Convert public key to bitcoin address.
10
+ */
11
+ export declare function publicKeyToAddress(publicKey: string, type: AddressType, networkType: NetworkType): string;
12
+ /**
13
+ * Convert public key to bitcoin scriptPk.
14
+ */
15
+ export declare function publicKeyToScriptPk(publicKey: string, type: AddressType, networkType: NetworkType): string | undefined;
16
+ /**
17
+ * Convert bitcoin address to scriptPk.
18
+ */
19
+ export declare function addressToScriptPk(address: string, networkType: NetworkType): Buffer<ArrayBufferLike>;
20
+ /**
21
+ * Check if the address is valid.
22
+ */
23
+ export declare function isValidAddress(address: string, networkType?: NetworkType): boolean;
24
+ export declare function decodeAddress(address: string): {
25
+ networkType: NetworkType;
26
+ addressType: AddressType;
27
+ dust: number;
28
+ };
29
+ /**
30
+ * Get address type.
31
+ */
32
+ export declare function getAddressType(address: string, networkType?: NetworkType): AddressType;
33
+ /**
34
+ * Convert scriptPk to address.
35
+ */
36
+ export declare function scriptPkToAddress(scriptPk: string | Buffer, networkType?: NetworkType): string;
@@ -0,0 +1,5 @@
1
+ import * as ecc from '@bitcoinerlab/secp256k1';
2
+ import * as bitcoin from '@btc-vision/bitcoin';
3
+ export declare const ECPair: import("ecpair").ECPairAPI;
4
+ export { ECPairInterface } from 'ecpair';
5
+ export { ecc, bitcoin };
@@ -0,0 +1 @@
1
+ export declare const UTXO_DUST = 546;
package/lib/error.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export declare enum ErrorCodes {
2
+ UNKNOWN = -1,
3
+ INSUFFICIENT_BTC_UTXO = -2,
4
+ INSUFFICIENT_ASSET_UTXO = -3,
5
+ NOT_SAFE_UTXOS = -4,
6
+ ASSET_MAYBE_LOST = -5,
7
+ ONLY_ONE_ARC20_CAN_BE_SENT = -6
8
+ }
9
+ export declare const ErrorMessages: {
10
+ [-1]: string;
11
+ [-2]: string;
12
+ [-3]: string;
13
+ [-4]: string;
14
+ [-5]: string;
15
+ [-6]: string;
16
+ };
17
+ export declare class WalletUtilsError extends Error {
18
+ code: ErrorCodes;
19
+ constructor(code: ErrorCodes, message?: string);
20
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export * as address from './address';
2
+ export * as core from './bitcoin-core';
3
+ export * from './constants';
4
+ export * as keyring from './keyring';
5
+ export * as message from './message';
6
+ export * as transaction from './transaction';
7
+ export * as txHelpers from './tx-helpers';
8
+ export * from './types';
9
+ export * as utils from './utils';
10
+ export * as wallet from './wallet';
11
+ export * from './keyring/interfaces/SimpleKeyringOptions';
12
+ export * from './keyring/hd-keyring';
13
+ export * from './keyring/keystone-keyring';
14
+ export * from './keyring/simple-keyring';
@@ -0,0 +1,50 @@
1
+ import bitcore from 'bitcore-lib';
2
+ import { ECPairInterface } from '../bitcoin-core';
3
+ import { DeserializeOption, IKeyringBase } from './interfaces/SimpleKeyringOptions';
4
+ export declare class HdKeyring extends IKeyringBase<DeserializeOption> {
5
+ static type: string;
6
+ type: string;
7
+ mnemonic: string | null;
8
+ xpriv: string | null;
9
+ passphrase: string | null;
10
+ hdPath: string;
11
+ root: bitcore.HDPrivateKey | null;
12
+ hdWallet?: any;
13
+ wallets: ECPairInterface[];
14
+ activeIndexes: number[];
15
+ page: number;
16
+ perPage: number;
17
+ private _index2wallet;
18
+ constructor(opts?: DeserializeOption);
19
+ serialize(): DeserializeOption;
20
+ deserialize(_opts?: DeserializeOption): void;
21
+ initFromXpriv(xpriv: string): void;
22
+ initFromMnemonic(mnemonic: string): void;
23
+ changeHdPath(hdPath: string): void;
24
+ getAccountByHdPath(hdPath: string, index: number): string;
25
+ addAccounts(numberOfAccounts?: number): string[];
26
+ activeAccounts(indexes: number[]): string[];
27
+ getFirstPage(): Promise<{
28
+ address: string;
29
+ index: number;
30
+ }[]>;
31
+ getNextPage(): Promise<{
32
+ address: string;
33
+ index: number;
34
+ }[]>;
35
+ getPreviousPage(): Promise<{
36
+ address: string;
37
+ index: number;
38
+ }[]>;
39
+ getAddresses(start: number, end: number): {
40
+ address: string;
41
+ index: number;
42
+ }[];
43
+ __getPage(increment: number): Promise<{
44
+ address: string;
45
+ index: number;
46
+ }[]>;
47
+ getAccounts(): string[];
48
+ getIndexByAddress(address: string): number | null;
49
+ private _addressFromIndex;
50
+ }
@@ -0,0 +1,4 @@
1
+ export * from './hd-keyring';
2
+ export * from './keystone-keyring';
3
+ export * from './simple-keyring';
4
+ export * from './interfaces/SimpleKeyringOptions';
@@ -0,0 +1,52 @@
1
+ import { Network, Psbt } from '@btc-vision/bitcoin';
2
+ import { ECPairInterface } from 'ecpair';
3
+ import { EventEmitter } from 'events';
4
+ interface BaseKeyringOptions {
5
+ readonly network?: Network;
6
+ }
7
+ export interface SimpleKeyringOptions extends BaseKeyringOptions {
8
+ readonly privateKeys?: string[];
9
+ }
10
+ export interface DeserializeOptionBase extends BaseKeyringOptions {
11
+ readonly hdPath?: string;
12
+ readonly activeIndexes?: number[];
13
+ }
14
+ export interface DeserializeOption extends DeserializeOptionBase {
15
+ readonly mnemonic?: string | null;
16
+ readonly xpriv?: string | null;
17
+ readonly passphrase?: string | null;
18
+ }
19
+ export interface KeystoneKey {
20
+ readonly path: string;
21
+ readonly extendedPublicKey: string;
22
+ }
23
+ export interface DeserializeOptionKeystone extends DeserializeOptionBase {
24
+ readonly mfp: string;
25
+ readonly keys: KeystoneKey[];
26
+ }
27
+ export type KeyringOptions = SimpleKeyringOptions | DeserializeOption | DeserializeOptionKeystone;
28
+ export declare abstract class IKeyringBase<T extends BaseKeyringOptions> extends EventEmitter {
29
+ readonly network: Network;
30
+ static type: string;
31
+ type: string;
32
+ protected wallets: ECPairInterface[];
33
+ protected constructor(network?: Network);
34
+ abstract serialize(): T;
35
+ abstract addAccounts(numberOfAccounts: number): string[];
36
+ abstract deserialize(opts?: T): unknown;
37
+ removeAccount(publicKey: string): void;
38
+ verifyMessage(publicKey: string, text: string, sig: string): Promise<boolean>;
39
+ signData(publicKey: string, data: string, type?: 'ecdsa' | 'schnorr'): string;
40
+ abstract getAccounts(): string[];
41
+ signMessage(publicKey: string, text: string): string;
42
+ exportAccount(publicKey: string): string | undefined;
43
+ signTransaction(psbt: Psbt, inputs: {
44
+ index: number;
45
+ publicKey: string;
46
+ sighashTypes?: number[];
47
+ disableTweakSigner?: boolean;
48
+ }[], opts?: any): Psbt;
49
+ private _getWalletForAccount;
50
+ private _getPrivateKeyFor;
51
+ }
52
+ export {};
@@ -0,0 +1,82 @@
1
+ import bitcore from 'bitcore-lib';
2
+ import { DeserializeOptionKeystone, IKeyringBase, KeystoneKey } from './interfaces/SimpleKeyringOptions';
3
+ interface Wallet {
4
+ index: number;
5
+ publicKey: string;
6
+ path: string;
7
+ }
8
+ export declare class KeystoneKeyring extends IKeyringBase<DeserializeOptionKeystone> {
9
+ static type: string;
10
+ type: string;
11
+ mfp: string;
12
+ keys: KeystoneKey[];
13
+ hdPath?: string;
14
+ activeIndexes: number[];
15
+ root: bitcore.HDPublicKey | undefined;
16
+ page: number;
17
+ perPage: number;
18
+ origin: string;
19
+ constructor(opts?: DeserializeOptionKeystone);
20
+ initFromUR(type: string, cbor: string): Promise<void>;
21
+ getHardenedPath(hdPath: string): string;
22
+ getHDPublicKey(hdPath: string): bitcore.HDPublicKey;
23
+ getDefaultHdPath(): string;
24
+ initRoot(): void;
25
+ deserialize(opts: DeserializeOptionKeystone): void;
26
+ serialize(): DeserializeOptionKeystone;
27
+ addAccounts(numberOfAccounts?: number): string[];
28
+ addChangeAddressAccounts(numberOfAccounts?: number): Promise<string[]>;
29
+ getAccounts(): string[];
30
+ getAccounts2(): Promise<{
31
+ index: number;
32
+ path: string;
33
+ publicKey: string;
34
+ }[]>;
35
+ getAccountsWithBrand(): Promise<{
36
+ address: string;
37
+ index: number;
38
+ }[]>;
39
+ getWalletByIndex(index: number): Wallet;
40
+ getChangeAddressWalletByIndex(index: number): Wallet;
41
+ removeAccount(publicKey: string): void;
42
+ exportAccount(_publicKey: string): string;
43
+ getFirstPage(): Promise<{
44
+ address: string;
45
+ index: number;
46
+ }[]>;
47
+ getNextPage(): Promise<{
48
+ address: string;
49
+ index: number;
50
+ }[]>;
51
+ getPreviousPage(): Promise<{
52
+ address: string;
53
+ index: number;
54
+ }[]>;
55
+ getAddresses(start: number, end: number): {
56
+ address: string;
57
+ index: number;
58
+ }[];
59
+ getPage(increment: number): Promise<{
60
+ address: string;
61
+ index: number;
62
+ }[]>;
63
+ activeAccounts(indexes: number[]): string[];
64
+ changeHdPath(hdPath: string): void;
65
+ changeChangeAddressHdPath(hdPath: string): never[];
66
+ getAccountByHdPath(hdPath: string, index: number): string;
67
+ getChangeAddressAccountByHdPath(hdPath: string, index: number): string;
68
+ genSignPsbtUr(psbtHex: string): Promise<{
69
+ type: string;
70
+ cbor: string;
71
+ }>;
72
+ parseSignPsbtUr(type: string, cbor: string): Promise<string>;
73
+ genSignMsgUr(publicKey: string, text: string): Promise<{
74
+ requestId: any;
75
+ type: string;
76
+ cbor: string;
77
+ }>;
78
+ parseSignMsgUr(type: string, cbor: string): Promise<import("@keystonehq/keystone-sdk").BtcSignature>;
79
+ signMessage(publicKey: string, text: string): string;
80
+ verifyMessage(publicKey: string, text: string, sig: string): Promise<boolean>;
81
+ }
82
+ export {};
@@ -0,0 +1,11 @@
1
+ import { IKeyringBase, SimpleKeyringOptions } from './interfaces/SimpleKeyringOptions';
2
+ export declare class SimpleKeyring extends IKeyringBase<SimpleKeyringOptions> {
3
+ static type: string;
4
+ type: string;
5
+ constructor(opts?: SimpleKeyringOptions);
6
+ serialize(): SimpleKeyringOptions;
7
+ deserialize(opts: SimpleKeyringOptions): void;
8
+ addAccounts(n?: number): string[];
9
+ getAccounts(): string[];
10
+ }
11
+ export declare function verifySignData(publicKey: string, hash: string, type: 'ecdsa' | 'schnorr', signature: string): boolean;
@@ -0,0 +1,19 @@
1
+ import * as bitcoin from '@btc-vision/bitcoin';
2
+ import { NetworkType } from '../network';
3
+ import { AbstractWallet } from '../wallet';
4
+ export declare function genPsbtOfBIP322Simple({ message, address, networkType }: {
5
+ message: string;
6
+ address: string;
7
+ networkType: NetworkType;
8
+ }): bitcoin.Psbt;
9
+ export declare function getSignatureFromPsbtOfBIP322Simple(psbt: bitcoin.Psbt): string;
10
+ /**
11
+ * reference: https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
12
+ */
13
+ export declare function signMessageOfBIP322Simple({ message, address, networkType, wallet }: {
14
+ message: string;
15
+ address: string;
16
+ networkType: NetworkType;
17
+ wallet: AbstractWallet;
18
+ }): Promise<string>;
19
+ export declare function verifyMessageOfBIP322Simple(address: string, msg: string, signature: string, networkType?: NetworkType): boolean;
@@ -0,0 +1,2 @@
1
+ import { ECPairInterface } from '../bitcoin-core';
2
+ export declare function signMessageOfDeterministicECDSA(ecpair: ECPairInterface, message: string): string;
@@ -0,0 +1,3 @@
1
+ import { ECPairInterface } from 'ecpair';
2
+ export declare function signMessageOfECDSA(privateKey: ECPairInterface, text: string): string;
3
+ export declare function verifyMessageOfECDSA(publicKey: string, text: string, sig: string): boolean;
@@ -0,0 +1,3 @@
1
+ export * from './bip322-simple';
2
+ export * from './deterministic-ecdsa';
3
+ export * from './ecdsa';
@@ -0,0 +1,14 @@
1
+ import { bitcoin } from '../bitcoin-core';
2
+ export declare enum NetworkType {
3
+ MAINNET = 0,
4
+ TESTNET = 1,
5
+ REGTEST = 2
6
+ }
7
+ /**
8
+ * Convert network type to @btc-vision/bitcoin network.
9
+ */
10
+ export declare function toPsbtNetwork(networkType: NetworkType): bitcoin.networks.Network;
11
+ /**
12
+ * Convert @btc-vision/bitcoin network to network type.
13
+ */
14
+ export declare function toNetworkType(network: bitcoin.Network): NetworkType;
@@ -0,0 +1 @@
1
+ export * from './varint';
@@ -0,0 +1,11 @@
1
+ export declare class RuneId {
2
+ block: number;
3
+ tx: number;
4
+ constructor({ block, tx }: {
5
+ block: number;
6
+ tx: number;
7
+ });
8
+ static fromBigInt(n: any): RuneId;
9
+ static fromString(s: string): RuneId;
10
+ toString(): string;
11
+ }
@@ -0,0 +1,14 @@
1
+ declare function try_decode(buf: any): (string | number)[];
2
+ declare function encodeToVec(n: any, v: any): void;
3
+ declare function decode(buffer: any): {
4
+ num: string | number;
5
+ index: string | number;
6
+ };
7
+ declare function encode(n: any): Buffer<ArrayBuffer>;
8
+ export declare const varint: {
9
+ encode: typeof encode;
10
+ decode: typeof decode;
11
+ try_decode: typeof try_decode;
12
+ encodeToVec: typeof encodeToVec;
13
+ };
14
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './inscription-utxo';
2
+ export * from './transaction';
3
+ export * from './utxo';
@@ -0,0 +1,33 @@
1
+ import { UnspentOutput } from '../types';
2
+ export declare class InscriptionUnit {
3
+ satoshis: number;
4
+ inscriptions: {
5
+ id: string;
6
+ outputOffset: number;
7
+ unitOffset: number;
8
+ }[];
9
+ constructor(satoshis: number, inscriptions: {
10
+ id: string;
11
+ outputOffset: number;
12
+ unitOffset: number;
13
+ }[]);
14
+ hasInscriptions(): boolean;
15
+ }
16
+ export declare class InscriptionUnspendOutput {
17
+ inscriptionUnits: InscriptionUnit[];
18
+ utxo: UnspentOutput;
19
+ constructor(utxo: UnspentOutput, outputValue?: number);
20
+ /**
21
+ * Get non-Ord satoshis for spending
22
+ */
23
+ getNonInscriptionSatoshis(): number;
24
+ /**
25
+ * Get last non-ord satoshis for spending.
26
+ * Only the last one is available
27
+ * @returns
28
+ */
29
+ getLastUnitSatoshis(): number;
30
+ hasInscriptions(): boolean;
31
+ dump(): void;
32
+ private split;
33
+ }
@@ -0,0 +1,51 @@
1
+ import { bitcoin } from '../bitcoin-core';
2
+ import { NetworkType } from '../network';
3
+ import { ToSignInput, UnspentOutput } from '../types';
4
+ interface TxOutput {
5
+ address?: string;
6
+ script?: Buffer;
7
+ value: number;
8
+ }
9
+ /**
10
+ * Transaction
11
+ */
12
+ export declare class Transaction {
13
+ outputs: TxOutput[];
14
+ changedAddress: string;
15
+ private utxos;
16
+ private inputs;
17
+ private changeOutputIndex;
18
+ private networkType;
19
+ private feeRate;
20
+ private enableRBF;
21
+ private _cacheNetworkFee;
22
+ private _cacheBtcUtxos;
23
+ private _cacheToSignInputs;
24
+ constructor();
25
+ setNetworkType(network: NetworkType): void;
26
+ setEnableRBF(enable: boolean): void;
27
+ setFeeRate(feeRate: number): void;
28
+ setChangeAddress(address: string): void;
29
+ addInput(utxo: UnspentOutput): void;
30
+ removeLastInput(): void;
31
+ getTotalInput(): number;
32
+ getTotalOutput(): number;
33
+ getUnspent(): number;
34
+ calNetworkFee(): Promise<number>;
35
+ addOutput(address: string, value: number): void;
36
+ addOpreturn(data: Buffer[]): void;
37
+ addScriptOutput(script: Buffer, value: number): void;
38
+ getOutput(index: number): TxOutput;
39
+ addChangeOutput(value: number): void;
40
+ getChangeOutput(): TxOutput;
41
+ getChangeAmount(): number;
42
+ removeChangeOutput(): void;
43
+ removeRecentOutputs(count: number): void;
44
+ toPsbt(): bitcoin.Psbt;
45
+ clone(): Transaction;
46
+ createEstimatePsbt(): Promise<bitcoin.Psbt>;
47
+ addSufficientUtxosForFee(btcUtxos: UnspentOutput[], forceAsFee?: boolean): Promise<ToSignInput[]>;
48
+ dumpTx(psbt: any): Promise<void>;
49
+ private selectBtcUtxos;
50
+ }
51
+ export {};
@@ -0,0 +1,35 @@
1
+ import { NetworkType } from '../network';
2
+ import { AddressType, UnspentOutput } from '../types';
3
+ declare function hasInscription(utxos: UnspentOutput[]): boolean;
4
+ declare function hasAtomicalsFT(utxos: UnspentOutput[]): boolean;
5
+ declare function hasAtomicalsNFT(utxos: UnspentOutput[]): boolean;
6
+ declare function hasAtomicals(utxos: UnspentOutput[]): boolean;
7
+ declare function hasAnyAssets(utxos: UnspentOutput[]): boolean;
8
+ /**
9
+ * select utxos so that the total amount of utxos is greater than or equal to targetAmount
10
+ * return the selected utxos and the unselected utxos
11
+ * @param utxos
12
+ * @param targetAmount
13
+ */
14
+ declare function selectBtcUtxos(utxos: UnspentOutput[], targetAmount: number): {
15
+ selectedUtxos: UnspentOutput[];
16
+ remainingUtxos: UnspentOutput[];
17
+ };
18
+ /**
19
+ * return the added virtual size of the utxo
20
+ */
21
+ declare function getAddedVirtualSize(addressType: AddressType): number;
22
+ export declare function getUtxoDust(addressType: AddressType): 546 | 294 | 330;
23
+ export declare function getAddressUtxoDust(address: string, networkType?: NetworkType): number;
24
+ export declare const utxoHelper: {
25
+ hasAtomicalsFT: typeof hasAtomicalsFT;
26
+ hasAtomicalsNFT: typeof hasAtomicalsNFT;
27
+ hasAtomicals: typeof hasAtomicals;
28
+ hasInscription: typeof hasInscription;
29
+ hasAnyAssets: typeof hasAnyAssets;
30
+ selectBtcUtxos: typeof selectBtcUtxos;
31
+ getAddedVirtualSize: typeof getAddedVirtualSize;
32
+ getUtxoDust: typeof getUtxoDust;
33
+ getAddressUtxoDust: typeof getAddressUtxoDust;
34
+ };
35
+ export {};
@@ -0,0 +1,8 @@
1
+ import { sendAtomicalsFT } from './send-atomicals-ft';
2
+ import { sendAtomicalsNFT } from './send-atomicals-nft';
3
+ import { sendAllBTC, sendBTC } from './send-btc';
4
+ import { sendInscription } from './send-inscription';
5
+ import { sendInscriptions } from './send-inscriptions';
6
+ import { sendRunes } from './send-runes';
7
+ import { splitInscriptionUtxo } from './split-inscription-utxo';
8
+ export { sendAllBTC, sendAtomicalsFT, sendAtomicalsNFT, sendBTC, sendInscription, sendInscriptions, sendRunes, splitInscriptionUtxo };
@@ -0,0 +1,16 @@
1
+ import { NetworkType } from '../network';
2
+ import { ToSignInput, UnspentOutput } from '../types';
3
+ export declare function sendAtomicalsFT(params: {
4
+ assetUtxos: UnspentOutput[];
5
+ btcUtxos: UnspentOutput[];
6
+ toAddress: string;
7
+ networkType: NetworkType;
8
+ changeAssetAddress: string;
9
+ sendAmount: number;
10
+ changeAddress: string;
11
+ feeRate: number;
12
+ enableRBF?: boolean;
13
+ }): Promise<{
14
+ psbt: import("@btc-vision/bitcoin").Psbt;
15
+ toSignInputs: ToSignInput[];
16
+ }>;
@@ -0,0 +1,14 @@
1
+ import { NetworkType } from '../network';
2
+ import { ToSignInput, UnspentOutput } from '../types';
3
+ export declare function sendAtomicalsNFT(params: {
4
+ assetUtxo: UnspentOutput;
5
+ btcUtxos: UnspentOutput[];
6
+ toAddress: string;
7
+ networkType: NetworkType;
8
+ changeAddress: string;
9
+ feeRate: number;
10
+ enableRBF?: boolean;
11
+ }): Promise<{
12
+ psbt: import("@btc-vision/bitcoin").Psbt;
13
+ toSignInputs: ToSignInput[];
14
+ }>;
@@ -0,0 +1,28 @@
1
+ import { NetworkType } from '../network';
2
+ import { ToSignInput, UnspentOutput } from '../types';
3
+ export declare function sendBTC(params: {
4
+ btcUtxos: UnspentOutput[];
5
+ tos: {
6
+ address: string;
7
+ satoshis: number;
8
+ }[];
9
+ networkType: NetworkType;
10
+ changeAddress: string;
11
+ feeRate: number;
12
+ enableRBF?: boolean;
13
+ memo?: string;
14
+ memos?: string[];
15
+ }): Promise<{
16
+ psbt: import("@btc-vision/bitcoin").Psbt;
17
+ toSignInputs: ToSignInput[];
18
+ }>;
19
+ export declare function sendAllBTC(params: {
20
+ btcUtxos: UnspentOutput[];
21
+ toAddress: string;
22
+ networkType: NetworkType;
23
+ feeRate: number;
24
+ enableRBF?: boolean;
25
+ }): Promise<{
26
+ psbt: import("@btc-vision/bitcoin").Psbt;
27
+ toSignInputs: ToSignInput[];
28
+ }>;
@@ -0,0 +1,16 @@
1
+ import { NetworkType } from '../network';
2
+ import { UnspentOutput } from '../types';
3
+ export declare function sendInscription({ assetUtxo, btcUtxos, toAddress, networkType, changeAddress, feeRate, outputValue, enableRBF, enableMixed }: {
4
+ assetUtxo: UnspentOutput;
5
+ btcUtxos: UnspentOutput[];
6
+ toAddress: string;
7
+ networkType: NetworkType;
8
+ changeAddress: string;
9
+ feeRate: number;
10
+ outputValue: number;
11
+ enableRBF?: boolean;
12
+ enableMixed?: boolean;
13
+ }): Promise<{
14
+ psbt: import("@btc-vision/bitcoin").Psbt;
15
+ toSignInputs: import("../types").ToSignInput[];
16
+ }>;
@@ -0,0 +1,14 @@
1
+ import { NetworkType } from '../network';
2
+ import { ToSignInput, UnspentOutput } from '../types';
3
+ export declare function sendInscriptions({ assetUtxos, btcUtxos, toAddress, networkType, changeAddress, feeRate, enableRBF }: {
4
+ assetUtxos: UnspentOutput[];
5
+ btcUtxos: UnspentOutput[];
6
+ toAddress: string;
7
+ networkType: NetworkType;
8
+ changeAddress: string;
9
+ feeRate: number;
10
+ enableRBF?: boolean;
11
+ }): Promise<{
12
+ psbt: import("@btc-vision/bitcoin").Psbt;
13
+ toSignInputs: ToSignInput[];
14
+ }>;
@@ -0,0 +1,19 @@
1
+ import { bitcoin } from '../bitcoin-core';
2
+ import { NetworkType } from '../network';
3
+ import { ToSignInput, UnspentOutput } from '../types';
4
+ export declare function sendRunes({ assetUtxos, btcUtxos, assetAddress, btcAddress, toAddress, networkType, runeid, runeAmount, outputValue, feeRate, enableRBF }: {
5
+ assetUtxos: UnspentOutput[];
6
+ btcUtxos: UnspentOutput[];
7
+ assetAddress: string;
8
+ btcAddress: string;
9
+ toAddress: string;
10
+ networkType: NetworkType;
11
+ runeid: string;
12
+ runeAmount: string;
13
+ outputValue: number;
14
+ feeRate: number;
15
+ enableRBF?: boolean;
16
+ }): Promise<{
17
+ psbt: bitcoin.Psbt;
18
+ toSignInputs: ToSignInput[];
19
+ }>;
@@ -0,0 +1,15 @@
1
+ import { NetworkType } from '../network';
2
+ import { ToSignInput, UnspentOutput } from '../types';
3
+ export declare function splitInscriptionUtxo({ btcUtxos, assetUtxo, networkType, changeAddress, feeRate, enableRBF, outputValue }: {
4
+ btcUtxos: UnspentOutput[];
5
+ assetUtxo: UnspentOutput;
6
+ networkType: NetworkType;
7
+ changeAddress: string;
8
+ feeRate?: number;
9
+ enableRBF?: boolean;
10
+ outputValue?: number;
11
+ }): Promise<{
12
+ psbt: import("@btc-vision/bitcoin").Psbt;
13
+ toSignInputs: ToSignInput[];
14
+ splitedCount: number;
15
+ }>;
package/lib/types.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ interface BaseUserToSignInput {
2
+ index: number;
3
+ sighashTypes?: number[] | undefined;
4
+ disableTweakSigner?: boolean;
5
+ }
6
+ export interface AddressUserToSignInput extends BaseUserToSignInput {
7
+ address: string;
8
+ }
9
+ export interface PublicKeyUserToSignInput extends BaseUserToSignInput {
10
+ publicKey: string;
11
+ }
12
+ export type UserToSignInput = AddressUserToSignInput | PublicKeyUserToSignInput;
13
+ export interface SignPsbtOptions {
14
+ autoFinalized?: boolean;
15
+ toSignInputs?: UserToSignInput[];
16
+ }
17
+ export interface ToSignInput {
18
+ index: number;
19
+ publicKey: string;
20
+ sighashTypes?: number[];
21
+ disableTweakSigner?: boolean;
22
+ }
23
+ export interface UnspentOutput {
24
+ txid: string;
25
+ vout: number;
26
+ satoshis: number;
27
+ scriptPk: string;
28
+ pubkey: string;
29
+ addressType: AddressType;
30
+ inscriptions: {
31
+ inscriptionId: string;
32
+ inscriptionNumber?: number;
33
+ offset: number;
34
+ }[];
35
+ atomicals: {
36
+ atomicalId: string;
37
+ atomicalNumber: number;
38
+ type: 'FT' | 'NFT';
39
+ ticker?: string;
40
+ atomicalValue?: number;
41
+ }[];
42
+ runes?: {
43
+ runeid: string;
44
+ amount: string;
45
+ }[];
46
+ rawtx?: string;
47
+ }
48
+ export declare enum AddressType {
49
+ P2PKH = 0,
50
+ P2WPKH = 1,
51
+ P2TR = 2,
52
+ P2SH_P2WPKH = 3,
53
+ M44_P2WPKH = 4,// deprecated
54
+ M44_P2TR = 5,// deprecated
55
+ P2WSH = 6,
56
+ P2SH = 7,
57
+ UNKNOWN = 8
58
+ }
59
+ export {};
package/lib/utils.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { bitcoin } from './bitcoin-core';
2
+ export declare const toXOnly: (pubKey: Buffer) => Buffer<ArrayBufferLike>;
3
+ /**
4
+ * Transform raw private key to taproot address private key
5
+ */
6
+ export declare function tweakSigner(signer: bitcoin.Signer, opts?: any): bitcoin.Signer;
7
+ /**
8
+ * ECDSA signature validator
9
+ */
10
+ export declare const validator: (pubkey: Buffer, msghash: Buffer, signature: Buffer) => boolean;
11
+ /**
12
+ * Schnorr signature validator
13
+ */
14
+ export declare const schnorrValidator: (pubkey: Buffer, msghash: Buffer, signature: Buffer) => boolean;
15
+ /**
16
+ * Transform satoshis to btc format
17
+ */
18
+ export declare function satoshisToAmount(val: number): string;
19
+ /**
20
+ * Transform btc format to satoshis
21
+ */
22
+ export declare function amountToSaothis(val: any): number;
23
+ export declare function shortAddress(address?: string, len?: number): string;
@@ -0,0 +1,6 @@
1
+ import { bitcoin } from '../bitcoin-core';
2
+ import { SignPsbtOptions } from '../types';
3
+ export interface AbstractWallet {
4
+ signPsbt(psbt: bitcoin.Psbt, opts?: SignPsbtOptions): Promise<bitcoin.Psbt>;
5
+ signMessage(text: string, type: 'bip322-simple' | 'ecdsa'): Promise<string>;
6
+ }
@@ -0,0 +1,23 @@
1
+ import { bitcoin } from '../bitcoin-core';
2
+ import { SimpleKeyring } from '../keyring';
3
+ import { NetworkType } from '../network';
4
+ import { AddressType, SignPsbtOptions } from '../types';
5
+ import { AbstractWallet } from './abstract-wallet';
6
+ /**
7
+ * EstimateWallet is a wallet that can be used to estimate the size of a transaction.
8
+ */
9
+ export declare class EstimateWallet implements AbstractWallet {
10
+ keyring: SimpleKeyring;
11
+ address: string;
12
+ pubkey: string;
13
+ network: bitcoin.Network;
14
+ networkType: NetworkType;
15
+ addressType: AddressType;
16
+ constructor(wif: string, networkType?: NetworkType, addressType?: AddressType);
17
+ static fromRandom(addressType?: AddressType, networkType?: NetworkType): EstimateWallet;
18
+ getNetworkType(): NetworkType;
19
+ signPsbt(psbt: bitcoin.Psbt, opts?: SignPsbtOptions): Promise<bitcoin.Psbt>;
20
+ getPublicKey(): Promise<string>;
21
+ signMessage(text: string, type: 'bip322-simple' | 'ecdsa'): Promise<string>;
22
+ private formatOptionsToSignInputs;
23
+ }
@@ -0,0 +1,3 @@
1
+ export * from './abstract-wallet';
2
+ export * from './estimate-wallet';
3
+ export * from './local-wallet';
@@ -0,0 +1,23 @@
1
+ import { bitcoin } from '../bitcoin-core';
2
+ import { SimpleKeyring } from '../keyring';
3
+ import { NetworkType } from '../network';
4
+ import { AddressType, SignPsbtOptions } from '../types';
5
+ import { AbstractWallet } from './abstract-wallet';
6
+ export declare class LocalWallet implements AbstractWallet {
7
+ keyring: SimpleKeyring;
8
+ address: string;
9
+ pubkey: string;
10
+ network: bitcoin.Network;
11
+ addressType: AddressType;
12
+ networkType: NetworkType;
13
+ scriptPk: string | undefined;
14
+ constructor(wif: string, addressType?: AddressType, networkType?: NetworkType);
15
+ static fromMnemonic(addressType: AddressType, networkType: NetworkType, mnemonic: string, passPhrase?: string, hdPath?: string): LocalWallet;
16
+ static fromRandom(addressType?: AddressType, networkType?: NetworkType): LocalWallet;
17
+ getNetworkType(): NetworkType;
18
+ signPsbt(psbt: bitcoin.Psbt, opts?: SignPsbtOptions): Promise<bitcoin.Psbt>;
19
+ getPublicKey(): string;
20
+ signMessage(text: string, type: 'bip322-simple' | 'ecdsa'): Promise<string>;
21
+ signData(data: string, type?: 'ecdsa' | 'schnorr'): Promise<string>;
22
+ private formatOptionsToSignInputs;
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btc-vision/wallet-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "OP_WALLET SDK",
5
5
  "keywords": [
6
6
  "bitcoin",