@btc-vision/wallet-sdk 1.0.0
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.
- package/LICENSE +15 -0
- package/README.md +24 -0
- package/es/bundle.js +2 -0
- package/es/bundle.js.LICENSE.txt +48 -0
- package/lib/address/index.d.ts +37 -0
- package/lib/address/index.js +235 -0
- package/lib/bitcoin-core.d.ts +5 -0
- package/lib/bitcoin-core.js +37 -0
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +5 -0
- package/lib/error.d.ts +20 -0
- package/lib/error.js +29 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +50 -0
- package/lib/keyring/hd-keyring.d.ts +50 -0
- package/lib/keyring/hd-keyring.js +238 -0
- package/lib/keyring/index.d.ts +4 -0
- package/lib/keyring/index.js +20 -0
- package/lib/keyring/interfaces/SimpleKeyringOptions.d.ts +53 -0
- package/lib/keyring/interfaces/SimpleKeyringOptions.js +85 -0
- package/lib/keyring/keystone-keyring.d.ts +82 -0
- package/lib/keyring/keystone-keyring.js +377 -0
- package/lib/keyring/simple-keyring.d.ts +11 -0
- package/lib/keyring/simple-keyring.js +66 -0
- package/lib/message/bip322-simple.d.ts +19 -0
- package/lib/message/bip322-simple.js +182 -0
- package/lib/message/deterministic-ecdsa.d.ts +2 -0
- package/lib/message/deterministic-ecdsa.js +83 -0
- package/lib/message/ecdsa.d.ts +3 -0
- package/lib/message/ecdsa.js +32 -0
- package/lib/message/index.d.ts +3 -0
- package/lib/message/index.js +19 -0
- package/lib/network/index.d.ts +14 -0
- package/lib/network/index.js +40 -0
- package/lib/runes/index.d.ts +1 -0
- package/lib/runes/index.js +17 -0
- package/lib/runes/rund_id.d.ts +11 -0
- package/lib/runes/rund_id.js +30 -0
- package/lib/runes/varint.d.ts +15 -0
- package/lib/runes/varint.js +45 -0
- package/lib/src/address/index.d.ts +37 -0
- package/lib/src/bitcoin-core.d.ts +5 -0
- package/lib/src/constants.d.ts +1 -0
- package/lib/src/error.d.ts +20 -0
- package/lib/src/index.d.ts +14 -0
- package/lib/src/keyring/hd-keyring.d.ts +50 -0
- package/lib/src/keyring/index.d.ts +4 -0
- package/lib/src/keyring/interfaces/SimpleKeyringOptions.d.ts +53 -0
- package/lib/src/keyring/keystone-keyring.d.ts +82 -0
- package/lib/src/keyring/simple-keyring.d.ts +11 -0
- package/lib/src/message/bip322-simple.d.ts +19 -0
- package/lib/src/message/deterministic-ecdsa.d.ts +2 -0
- package/lib/src/message/ecdsa.d.ts +3 -0
- package/lib/src/message/index.d.ts +3 -0
- package/lib/src/network/index.d.ts +14 -0
- package/lib/src/runes/index.d.ts +1 -0
- package/lib/src/runes/rund_id.d.ts +11 -0
- package/lib/src/runes/varint.d.ts +15 -0
- package/lib/src/transaction/index.d.ts +3 -0
- package/lib/src/transaction/inscription-utxo.d.ts +33 -0
- package/lib/src/transaction/transaction.d.ts +52 -0
- package/lib/src/transaction/utxo.d.ts +35 -0
- package/lib/src/tx-helpers/index.d.ts +8 -0
- package/lib/src/tx-helpers/send-atomicals-ft.d.ts +16 -0
- package/lib/src/tx-helpers/send-atomicals-nft.d.ts +14 -0
- package/lib/src/tx-helpers/send-btc.d.ts +28 -0
- package/lib/src/tx-helpers/send-inscription.d.ts +16 -0
- package/lib/src/tx-helpers/send-inscriptions.d.ts +14 -0
- package/lib/src/tx-helpers/send-runes.d.ts +19 -0
- package/lib/src/tx-helpers/split-inscription-utxo.d.ts +15 -0
- package/lib/src/types.d.ts +59 -0
- package/lib/src/utils.d.ts +23 -0
- package/lib/src/wallet/abstract-wallet.d.ts +6 -0
- package/lib/src/wallet/estimate-wallet.d.ts +23 -0
- package/lib/src/wallet/index.d.ts +3 -0
- package/lib/src/wallet/local-wallet.d.ts +23 -0
- package/lib/test/address/address.test.d.ts +1 -0
- package/lib/test/keyring/hd-keyring.test.d.ts +1 -0
- package/lib/test/keyring/keystone-keyring.test.d.ts +1 -0
- package/lib/test/keyring/simple-keyring.test.d.ts +1 -0
- package/lib/test/message/message.test.d.ts +1 -0
- package/lib/test/runes/varint.test.d.ts +1 -0
- package/lib/test/transaction/transaction.test.d.ts +1 -0
- package/lib/test/transaction/utxo.test.d.ts +1 -0
- package/lib/test/tx-helpers/send-atomicals-ft.test.d.ts +1 -0
- package/lib/test/tx-helpers/send-atomicals-nft.test.d.ts +1 -0
- package/lib/test/tx-helpers/send-btc.test.d.ts +1 -0
- package/lib/test/tx-helpers/send-inscription.test.d.ts +1 -0
- package/lib/test/tx-helpers/send-inscriptions.test.d.ts +1 -0
- package/lib/test/tx-helpers/send-runes.test.d.ts +1 -0
- package/lib/test/tx-helpers/split-inscription-utxo.test.d.ts +1 -0
- package/lib/test/tx-helpers/utils.d.ts +217 -0
- package/lib/test/utils.d.ts +4 -0
- package/lib/test/wallet/local-wallet.test.d.ts +1 -0
- package/lib/transaction/index.d.ts +3 -0
- package/lib/transaction/index.js +19 -0
- package/lib/transaction/inscription-utxo.d.ts +33 -0
- package/lib/transaction/inscription-utxo.js +120 -0
- package/lib/transaction/transaction.d.ts +52 -0
- package/lib/transaction/transaction.js +358 -0
- package/lib/transaction/utxo.d.ts +35 -0
- package/lib/transaction/utxo.js +107 -0
- package/lib/tx-helpers/index.d.ts +8 -0
- package/lib/tx-helpers/index.js +18 -0
- package/lib/tx-helpers/send-atomicals-ft.d.ts +16 -0
- package/lib/tx-helpers/send-atomicals-ft.js +66 -0
- package/lib/tx-helpers/send-atomicals-nft.d.ts +14 -0
- package/lib/tx-helpers/send-atomicals-nft.js +45 -0
- package/lib/tx-helpers/send-btc.d.ts +28 -0
- package/lib/tx-helpers/send-btc.js +78 -0
- package/lib/tx-helpers/send-inscription.d.ts +16 -0
- package/lib/tx-helpers/send-inscription.js +49 -0
- package/lib/tx-helpers/send-inscriptions.d.ts +14 -0
- package/lib/tx-helpers/send-inscriptions.js +45 -0
- package/lib/tx-helpers/send-runes.d.ts +19 -0
- package/lib/tx-helpers/send-runes.js +101 -0
- package/lib/tx-helpers/split-inscription-utxo.d.ts +15 -0
- package/lib/tx-helpers/split-inscription-utxo.js +58 -0
- package/lib/types.d.ts +59 -0
- package/lib/types.js +15 -0
- package/lib/utils.d.ts +23 -0
- package/lib/utils.js +71 -0
- package/lib/wallet/abstract-wallet.d.ts +6 -0
- package/lib/wallet/abstract-wallet.js +2 -0
- package/lib/wallet/estimate-wallet.d.ts +23 -0
- package/lib/wallet/estimate-wallet.js +174 -0
- package/lib/wallet/index.d.ts +3 -0
- package/lib/wallet/index.js +19 -0
- package/lib/wallet/local-wallet.d.ts +23 -0
- package/lib/wallet/local-wallet.js +183 -0
- package/package.json +97 -0
|
@@ -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 bitcoinjs-lib network.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toPsbtNetwork(networkType: NetworkType): bitcoin.networks.Network;
|
|
11
|
+
/**
|
|
12
|
+
* Convert bitcoinjs-lib network to network type.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toNetworkType(network: bitcoin.Network): NetworkType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './varint';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
declare function try_decode(buf: any): (string | number)[];
|
|
3
|
+
declare function encodeToVec(n: any, v: any): void;
|
|
4
|
+
declare function decode(buffer: any): {
|
|
5
|
+
num: string | number;
|
|
6
|
+
index: string | number;
|
|
7
|
+
};
|
|
8
|
+
declare function encode(n: any): Buffer;
|
|
9
|
+
export declare const varint: {
|
|
10
|
+
encode: typeof encode;
|
|
11
|
+
decode: typeof decode;
|
|
12
|
+
try_decode: typeof try_decode;
|
|
13
|
+
encodeToVec: typeof encodeToVec;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -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
|
+
private split;
|
|
21
|
+
/**
|
|
22
|
+
* Get non-Ord satoshis for spending
|
|
23
|
+
*/
|
|
24
|
+
getNonInscriptionSatoshis(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Get last non-ord satoshis for spending.
|
|
27
|
+
* Only the last one is available
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
getLastUnitSatoshis(): number;
|
|
31
|
+
hasInscriptions(): boolean;
|
|
32
|
+
dump(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { bitcoin } from '../bitcoin-core';
|
|
3
|
+
import { NetworkType } from '../network';
|
|
4
|
+
import { ToSignInput, UnspentOutput } from '../types';
|
|
5
|
+
interface TxOutput {
|
|
6
|
+
address?: string;
|
|
7
|
+
script?: Buffer;
|
|
8
|
+
value: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Transaction
|
|
12
|
+
*/
|
|
13
|
+
export declare class Transaction {
|
|
14
|
+
private utxos;
|
|
15
|
+
private inputs;
|
|
16
|
+
outputs: TxOutput[];
|
|
17
|
+
private changeOutputIndex;
|
|
18
|
+
changedAddress: string;
|
|
19
|
+
private networkType;
|
|
20
|
+
private feeRate;
|
|
21
|
+
private enableRBF;
|
|
22
|
+
private _cacheNetworkFee;
|
|
23
|
+
private _cacheBtcUtxos;
|
|
24
|
+
private _cacheToSignInputs;
|
|
25
|
+
constructor();
|
|
26
|
+
setNetworkType(network: NetworkType): void;
|
|
27
|
+
setEnableRBF(enable: boolean): void;
|
|
28
|
+
setFeeRate(feeRate: number): void;
|
|
29
|
+
setChangeAddress(address: string): void;
|
|
30
|
+
addInput(utxo: UnspentOutput): void;
|
|
31
|
+
removeLastInput(): void;
|
|
32
|
+
getTotalInput(): number;
|
|
33
|
+
getTotalOutput(): number;
|
|
34
|
+
getUnspent(): number;
|
|
35
|
+
calNetworkFee(): Promise<number>;
|
|
36
|
+
addOutput(address: string, value: number): void;
|
|
37
|
+
addOpreturn(data: Buffer[]): void;
|
|
38
|
+
addScriptOutput(script: Buffer, value: number): void;
|
|
39
|
+
getOutput(index: number): TxOutput;
|
|
40
|
+
addChangeOutput(value: number): void;
|
|
41
|
+
getChangeOutput(): TxOutput;
|
|
42
|
+
getChangeAmount(): number;
|
|
43
|
+
removeChangeOutput(): void;
|
|
44
|
+
removeRecentOutputs(count: number): void;
|
|
45
|
+
toPsbt(): bitcoin.Psbt;
|
|
46
|
+
clone(): Transaction;
|
|
47
|
+
createEstimatePsbt(): Promise<bitcoin.Psbt>;
|
|
48
|
+
private selectBtcUtxos;
|
|
49
|
+
addSufficientUtxosForFee(btcUtxos: UnspentOutput[], forceAsFee?: boolean): Promise<ToSignInput[]>;
|
|
50
|
+
dumpTx(psbt: any): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
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("bitcoinjs-lib").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("bitcoinjs-lib").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("bitcoinjs-lib").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("bitcoinjs-lib").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("bitcoinjs-lib").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("bitcoinjs-lib").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("bitcoinjs-lib").Psbt;
|
|
13
|
+
toSignInputs: ToSignInput[];
|
|
14
|
+
splitedCount: number;
|
|
15
|
+
}>;
|
|
@@ -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,
|
|
54
|
+
M44_P2TR = 5,
|
|
55
|
+
P2WSH = 6,
|
|
56
|
+
P2SH = 7,
|
|
57
|
+
UNKNOWN = 8
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { bitcoin } from './bitcoin-core';
|
|
2
|
+
export declare const toXOnly: (pubKey: Buffer) => Buffer;
|
|
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,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;
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|