@dynamic-labs/bitcoin 3.0.0-alpha.9 → 3.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/CHANGELOG.md +620 -0
- package/package.json +7 -6
- package/src/BitcoinLocalStorageCache.cjs +0 -16
- package/src/BitcoinLocalStorageCache.d.ts +0 -7
- package/src/BitcoinLocalStorageCache.js +0 -16
- package/src/bitcoinProviderHelper.d.ts +1 -0
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs +170 -141
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.d.ts +8 -3
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js +171 -142
- package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.cjs +216 -0
- package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.d.ts +11 -0
- package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.js +212 -0
- package/src/connectors/BitcoinSatsConnectLegacyConnector/index.d.ts +1 -0
- package/src/connectors/BitcoinWalletConnector.cjs +44 -29
- package/src/connectors/BitcoinWalletConnector.d.ts +7 -3
- package/src/connectors/BitcoinWalletConnector.js +45 -30
- package/src/connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.cjs +7 -1
- package/src/connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.d.ts +1 -1
- package/src/connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.js +7 -1
- package/src/connectors/OkxConnector/OkxConnector.cjs +19 -2
- package/src/connectors/OkxConnector/OkxConnector.d.ts +1 -1
- package/src/connectors/OkxConnector/OkxConnector.js +19 -2
- package/src/connectors/PhantomConnector/PhantomConnector.cjs +4 -9
- package/src/connectors/PhantomConnector/PhantomConnector.d.ts +1 -2
- package/src/connectors/PhantomConnector/PhantomConnector.js +4 -9
- package/src/connectors/UnisatConnector/UnisatConnector.cjs +17 -1
- package/src/connectors/UnisatConnector/UnisatConnector.d.ts +1 -1
- package/src/connectors/UnisatConnector/UnisatConnector.js +17 -1
- package/src/connectors/UnknownInjected/UnknownInjected.cjs +7 -1
- package/src/connectors/UnknownInjected/UnknownInjected.d.ts +1 -1
- package/src/connectors/UnknownInjected/UnknownInjected.js +7 -1
- package/src/connectors/index.d.ts +1 -0
- package/src/index.cjs +4 -0
- package/src/index.d.ts +3 -2
- package/src/index.js +2 -0
- package/src/types.d.ts +1 -0
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs +15 -3
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js +15 -3
- package/src/utils/psbt/bitcoinNetworkTypeToNetworks.cjs +1 -0
- package/src/utils/psbt/bitcoinNetworkTypeToNetworks.d.ts +1 -1
- package/src/utils/psbt/bitcoinNetworkTypeToNetworks.js +1 -0
- package/src/utils/psbt/createSignPsbtOptions.cjs +22 -1
- package/src/utils/psbt/createSignPsbtOptions.d.ts +2 -0
- package/src/utils/psbt/createSignPsbtOptions.js +22 -2
- package/src/wallet/BitcoinWallet.cjs +69 -0
- package/src/wallet/BitcoinWallet.d.ts +36 -0
- package/src/wallet/BitcoinWallet.js +65 -0
- package/src/wallet/index.d.ts +2 -0
- package/src/wallet/isBitcoinWallet/index.d.ts +1 -0
- package/src/wallet/isBitcoinWallet/isBitcoinWallet.cjs +8 -0
- package/src/wallet/isBitcoinWallet/isBitcoinWallet.d.ts +3 -0
- package/src/wallet/isBitcoinWallet/isBitcoinWallet.js +4 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import type { WalletAddressType } from '@dynamic-labs/types';
|
|
3
|
+
import { BitcoinWalletConnector } from '../connectors';
|
|
4
|
+
import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinTransaction } from '../types';
|
|
5
|
+
export declare class BitcoinWallet extends Wallet<BitcoinWalletConnector> {
|
|
6
|
+
/**
|
|
7
|
+
* Sends a raw transaction
|
|
8
|
+
* @returns A promise that resolves to the transaction id
|
|
9
|
+
*/
|
|
10
|
+
sendRawTransaction(rawTransaction: string): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Sends satoshis to a bitcoin address
|
|
13
|
+
* @returns A promise that resolves to the transaction id
|
|
14
|
+
*/
|
|
15
|
+
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Signs a message using a specific address type (payment or ordinals).
|
|
18
|
+
* @param messageToSign - The message to sign.
|
|
19
|
+
* @param addressType - The type of address to sign the message with (payment or ordinals).
|
|
20
|
+
* @returns A promise that resolves to the signature of the message as a string,
|
|
21
|
+
* or undefined if the message cannot be signed.
|
|
22
|
+
*/
|
|
23
|
+
signMessageWithAddress(messageToSign: string, addressType: WalletAddressType): Promise<string | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Sings a PSBT
|
|
26
|
+
* @returns A promise that resolves to an object with the signed PSBT
|
|
27
|
+
* or undefined if no provider is available
|
|
28
|
+
*/
|
|
29
|
+
signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Sings multiple PSBTs
|
|
32
|
+
* @returns A promise that resolves to an array of signed PSBTs in base64
|
|
33
|
+
* or undefined if no provider is available
|
|
34
|
+
*/
|
|
35
|
+
signPsbts(requests: BitcoinSignPsbtRequest[]): Promise<string[] | undefined>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
|
|
5
|
+
class BitcoinWallet extends Wallet {
|
|
6
|
+
/**
|
|
7
|
+
* Sends a raw transaction
|
|
8
|
+
* @returns A promise that resolves to the transaction id
|
|
9
|
+
*/
|
|
10
|
+
sendRawTransaction(rawTransaction) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
yield this.sync();
|
|
13
|
+
return this._connector.sendRawTransaction(rawTransaction);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sends satoshis to a bitcoin address
|
|
18
|
+
* @returns A promise that resolves to the transaction id
|
|
19
|
+
*/
|
|
20
|
+
sendBitcoin(transaction) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
yield this.sync();
|
|
23
|
+
return this._connector.sendBitcoin(transaction);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Signs a message using a specific address type (payment or ordinals).
|
|
28
|
+
* @param messageToSign - The message to sign.
|
|
29
|
+
* @param addressType - The type of address to sign the message with (payment or ordinals).
|
|
30
|
+
* @returns A promise that resolves to the signature of the message as a string,
|
|
31
|
+
* or undefined if the message cannot be signed.
|
|
32
|
+
*/
|
|
33
|
+
signMessageWithAddress(messageToSign, addressType) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a;
|
|
36
|
+
yield this.sync();
|
|
37
|
+
const address = ((_a = this.additionalAddresses.find((addr) => addr.type === addressType)) === null || _a === void 0 ? void 0 : _a.address) || this.address;
|
|
38
|
+
return this._connector.signMessage(messageToSign, address);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sings a PSBT
|
|
43
|
+
* @returns A promise that resolves to an object with the signed PSBT
|
|
44
|
+
* or undefined if no provider is available
|
|
45
|
+
*/
|
|
46
|
+
signPsbt(request) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
yield this.sync();
|
|
49
|
+
return this._connector.signPsbt(request);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sings multiple PSBTs
|
|
54
|
+
* @returns A promise that resolves to an array of signed PSBTs in base64
|
|
55
|
+
* or undefined if no provider is available
|
|
56
|
+
*/
|
|
57
|
+
signPsbts(requests) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
yield this.sync();
|
|
60
|
+
return this._connector.signPsbts(requests);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { BitcoinWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isBitcoinWallet';
|