@argonprotocol/bitcoin 1.3.2 → 1.3.3

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.
@@ -0,0 +1,78 @@
1
+ import { Transaction } from '@scure/btc-signer';
2
+ export { Address, Transaction, p2pk, p2pkh, p2sh, p2wpkh, p2wsh } from '@scure/btc-signer';
3
+ import { HDKey, Versions } from '@scure/bip32';
4
+ export { HDKey } from '@scure/bip32';
5
+ import { IBitcoinLock, IReleaseRequest, ArgonPrimitivesBitcoinBitcoinNetwork } from '@argonprotocol/mainchain';
6
+ import { BTC_NETWORK } from '@scure/btc-signer/utils';
7
+ import * as bip39 from '@scure/bip39';
8
+ export { bip39 };
9
+
10
+ declare enum BitcoinNetwork {
11
+ /**
12
+ * Mainnet Bitcoin.
13
+ */
14
+ Bitcoin = 0,
15
+ /**
16
+ * Bitcoin's testnet network.
17
+ */
18
+ Testnet = 1,
19
+ /**
20
+ * Bitcoin's signet network
21
+ */
22
+ Signet = 2,
23
+ /**
24
+ * Bitcoin's regtest network.
25
+ */
26
+ Regtest = 3,
27
+ }
28
+
29
+ declare class CosignScript {
30
+ readonly lock: IBitcoinLock;
31
+ private network;
32
+ constructor(lock: IBitcoinLock, network: BitcoinNetwork);
33
+ getFundingPsbt(): Uint8Array;
34
+ calculateFee(feeRatePerSatVb: bigint, toScriptPubkey: string): bigint;
35
+ calculateScriptPubkey(): string;
36
+ getCosignPsbt(args: {
37
+ utxoRef: {
38
+ txid: string;
39
+ vout: number;
40
+ };
41
+ releaseRequest: IReleaseRequest;
42
+ }): Transaction;
43
+ psbtFromHex(psbtHex: string): Transaction;
44
+ /**
45
+ * Cosigns the PSBT with the vault xpub.
46
+ * @param psbt - The PSBT to cosign.
47
+ * @param lock - The Bitcoin lock containing the vault information.
48
+ * @param vaultXpriv - The vault's extended private key of which the xpub was used to create the vault.
49
+ */
50
+ vaultCosignPsbt(psbt: Transaction, lock: IBitcoinLock, vaultXpriv: HDKey): Transaction;
51
+ /**
52
+ * Cosigns the transaction.
53
+ */
54
+ cosignAndGenerateTx(args: {
55
+ releaseRequest: IReleaseRequest;
56
+ vaultCosignature: Uint8Array;
57
+ utxoRef: {
58
+ txid: string;
59
+ vout: number;
60
+ };
61
+ ownerXpriv: HDKey;
62
+ ownerXprivChildHdPath?: string;
63
+ addTx?: string;
64
+ }): Transaction;
65
+ }
66
+ declare function getBitcoinNetworkFromApi(network: ArgonPrimitivesBitcoinBitcoinNetwork): BitcoinNetwork;
67
+
68
+ declare function getBip32Version(network?: BitcoinNetwork): Versions | undefined;
69
+ declare function getChildXpriv(bip39Seed: Uint8Array, hdPath: string, network?: BitcoinNetwork): HDKey;
70
+ declare function getXpubFromXpriv(xpriv: HDKey): string;
71
+ declare function getCompressedPubkey(pubkey: string | Uint8Array): Uint8Array;
72
+ declare function getBech32Prefix(network: BitcoinNetwork): string;
73
+ declare function p2wshScriptHexToAddress(scriptPubKeyHex: string, network: BitcoinNetwork): string;
74
+ declare function addressBytesHex(address: string, network: BitcoinNetwork): string;
75
+ declare function keyToU8a(pubkey: string | Uint8Array): Uint8Array;
76
+ declare function getScureNetwork(network: BitcoinNetwork): BTC_NETWORK;
77
+
78
+ export { BitcoinNetwork, CosignScript, addressBytesHex, getBech32Prefix, getBip32Version, getBitcoinNetworkFromApi, getChildXpriv, getCompressedPubkey, getScureNetwork, getXpubFromXpriv, keyToU8a, p2wshScriptHexToAddress };