@meshsdk/bitcoin 1.9.0-beta.83 → 1.9.0-beta.85
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/dist/index.cjs +70 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -20
- package/dist/index.d.ts +69 -20
- package/dist/index.js +70 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5072,14 +5072,22 @@ var EmbeddedWallet = /*#__PURE__*/ function() {
|
|
|
5072
5072
|
{
|
|
5073
5073
|
key: "getAddresses",
|
|
5074
5074
|
value: /**
|
|
5075
|
-
*
|
|
5075
|
+
* Apps can specify which wallet addresses they require: Bitcoin ordinals address or Bitcoin payment address,
|
|
5076
|
+
* using the `purposes` request parameter. The `message` request param gives apps the option to display a
|
|
5077
|
+
* message to the user when requesting their addresses. (note: ignored for embedded wallets)
|
|
5076
5078
|
*
|
|
5077
|
-
* @param purposes Array of
|
|
5078
|
-
* - `'ordinals'`
|
|
5079
|
-
* - `'payment'`
|
|
5080
|
-
*
|
|
5081
|
-
* @param message Optional message to
|
|
5082
|
-
* @returns {Promise<GetAddressResult[]>}
|
|
5079
|
+
* @param purposes Array of strings used to specify the purpose of the address(es) to request:
|
|
5080
|
+
* - `'ordinals'` is preferably used to manage the user's ordinals
|
|
5081
|
+
* - `'payment'` is preferably used to manage the user's bitcoin
|
|
5082
|
+
* Example: `['ordinals', 'payment']`
|
|
5083
|
+
* @param message Optional - a message to be displayed to the user in the request prompt (ignored for embedded wallets)
|
|
5084
|
+
* @returns {Promise<GetAddressResult[]>} Once resolved, returns an array of the user's wallet address objects:
|
|
5085
|
+
* - `address`: string - the user's connected wallet address
|
|
5086
|
+
* - `publicKey`: A hex string representing the bytes of the public key of the account. You can use this to construct partially signed Bitcoin transactions (PSBT)
|
|
5087
|
+
* - `purpose`: string - The purpose of the address ('ordinals' for managing ordinals, 'payment' for managing bitcoin)
|
|
5088
|
+
* - `addressType`: string - the address's format ('P2TR' for ordinals, 'P2SH' for payment, 'P2WPKH' for payment using Ledger)
|
|
5089
|
+
* - `network`: string - the network where the address is being used ('mainnet', 'testnet', 'signet')
|
|
5090
|
+
* - `walletType`: string - the type of wallet used for the account ('ledger' for Ledger devices, 'software' otherwise)
|
|
5083
5091
|
* @throws {Error} If wallet is not properly initialized.
|
|
5084
5092
|
*/ function getAddresses(purposes, message) {
|
|
5085
5093
|
return _async_to_generator(function() {
|
|
@@ -5201,10 +5209,22 @@ var EmbeddedWallet = /*#__PURE__*/ function() {
|
|
|
5201
5209
|
{
|
|
5202
5210
|
key: "signMessage",
|
|
5203
5211
|
value: /**
|
|
5204
|
-
*
|
|
5212
|
+
* You can request to sign a message with wallet's Bitcoin addresses, by invoking the `signMessage` method.
|
|
5205
5213
|
*
|
|
5206
|
-
* @param params - Object containing
|
|
5207
|
-
*
|
|
5214
|
+
* @param params - Object containing the following parameters:
|
|
5215
|
+
* - `address`: a string representing the address to use to sign the message
|
|
5216
|
+
* - `message`: a string representing the message to be signed by the wallet
|
|
5217
|
+
* - `protocol` (optional): By default, signMessage will use two type of signatures depending on the Bitcoin address used for signing:
|
|
5218
|
+
* - ECDSA signatures over the secp256k1 curve when signing with the Bitcoin payment (`p2sh`) address
|
|
5219
|
+
* - BIP322 signatures when signing with the Bitcoin Ordinals (`p2tr`) address or a Ledger-based Bitcoin payment address (`p2wpkh`)
|
|
5220
|
+
*
|
|
5221
|
+
* You have the option to specify your preferred signature type with the `protocol` parameter:
|
|
5222
|
+
* - `ECDSA` to request ECDSA signatures over the secp256k1 curve (available for payment addresses only: `p2sh` and `p2wpkh`)
|
|
5223
|
+
* - `BIP322` to request BIP322 signatures (available for all payment (`p2sh` and `p2wpkh`) & ordinals addresses (`p2tr`))
|
|
5224
|
+
* @returns Promise that resolves to the `SignMessageResult` object containing:
|
|
5225
|
+
* - `signature`: a string representing the signed message
|
|
5226
|
+
* - `messageHash`: a string representing the hash of the message
|
|
5227
|
+
* - `address`: a string representing the address used for signing
|
|
5208
5228
|
* @throws {Error} If the wallet is read-only or private key is not available.
|
|
5209
5229
|
*/ function signMessage(params) {
|
|
5210
5230
|
return _async_to_generator(function() {
|
|
@@ -5245,9 +5265,24 @@ var EmbeddedWallet = /*#__PURE__*/ function() {
|
|
|
5245
5265
|
{
|
|
5246
5266
|
key: "signPsbt",
|
|
5247
5267
|
value: /**
|
|
5248
|
-
*
|
|
5249
|
-
*
|
|
5250
|
-
*
|
|
5268
|
+
* You can use the `signPsbt` method to request the signature of a Partially Signed Bitcoin Transaction (PSBT)
|
|
5269
|
+
* from Bitcoin wallet addresses.
|
|
5270
|
+
*
|
|
5271
|
+
* The PSBT to be signed must be base64-encoded. You can use any Bitcoin library to construct this transaction.
|
|
5272
|
+
*
|
|
5273
|
+
* @param params - Object containing the following parameters:
|
|
5274
|
+
* - `psbt`: a string representing the psbt to sign, encoded in base64
|
|
5275
|
+
* - `signInputs`: A Record<string, number[]> where:
|
|
5276
|
+
* - the keys are the addresses to use for signing
|
|
5277
|
+
* - the values are the indexes of the inputs to sign with each address
|
|
5278
|
+
* - `broadcast`: a boolean flag that specifies whether to broadcast the signed transaction after signature
|
|
5279
|
+
*
|
|
5280
|
+
* Depending on your use case, you can request that the PSBT be finalized and broadcasted after signing,
|
|
5281
|
+
* by setting the broadcast flag to true. Otherwise, the signed PSBT will be returned in the response without broadcasting.
|
|
5282
|
+
*
|
|
5283
|
+
* @returns Promise that resolves to the `SignPsbtResult` object containing:
|
|
5284
|
+
* - `psbt`: The base64 encoded signed PSBT
|
|
5285
|
+
* - `txid`: The transaction id as a hex-encoded string (only returned if the transaction was broadcasted)
|
|
5251
5286
|
* @throws {Error} If the wallet is read-only or private key is not available.
|
|
5252
5287
|
*/ function signPsbt(params) {
|
|
5253
5288
|
return _async_to_generator(function() {
|
|
@@ -5314,9 +5349,14 @@ var EmbeddedWallet = /*#__PURE__*/ function() {
|
|
|
5314
5349
|
{
|
|
5315
5350
|
key: "sendTransfer",
|
|
5316
5351
|
value: /**
|
|
5317
|
-
*
|
|
5318
|
-
*
|
|
5319
|
-
* @
|
|
5352
|
+
* You can use the `sendTransfer` method to request a transfer of any amount of Bitcoin to one or more recipients from the wallet.
|
|
5353
|
+
*
|
|
5354
|
+
* @param params - Object containing the following parameters:
|
|
5355
|
+
* - `recipients`: an array of objects with <address, amount> properties:
|
|
5356
|
+
* - `address`: a string representing the recipient's address
|
|
5357
|
+
* - `amount`: a number representing the amount of Bitcoin to send, denominated in satoshis (Bitcoin base unit)
|
|
5358
|
+
* @returns Promise that resolves to the `sendTransferResult` object containing:
|
|
5359
|
+
* - `txid`: The transaction id as a hex-encoded string
|
|
5320
5360
|
* @throws {Error} If the wallet is read-only or provider is not available.
|
|
5321
5361
|
*/ function sendTransfer(params) {
|
|
5322
5362
|
return _async_to_generator(function() {
|
|
@@ -5383,8 +5423,14 @@ var EmbeddedWallet = /*#__PURE__*/ function() {
|
|
|
5383
5423
|
{
|
|
5384
5424
|
key: "getBalance",
|
|
5385
5425
|
value: /**
|
|
5386
|
-
*
|
|
5387
|
-
*
|
|
5426
|
+
* You can use the `getBalance` method to retrieve Bitcoin balance.
|
|
5427
|
+
*
|
|
5428
|
+
* The `getBalance` method will return an object representing the connected wallet's payment address BTC holdings:
|
|
5429
|
+
*
|
|
5430
|
+
* @returns Promise that resolves to an object containing the following balance information:
|
|
5431
|
+
* - `confirmed`: a string representing the connected wallet's confirmed BTC balance, i.e. the amount of confirmed BTC which the payment address holds, in satoshis
|
|
5432
|
+
* - `unconfirmed`: a string representing the connected wallet's unconfirmed BTC balance, i.e. the amount of unconfirmed BTC which the payment address will send/receive as a result of pending mempool transactions, in satoshis (Note: this amount can be negative if the net result of pending mempool transaction decreases the address balance)
|
|
5433
|
+
* - `total`: a string representing the sum of confirmed and unconfirmed BTC balances
|
|
5388
5434
|
* @throws {Error} If provider is not available.
|
|
5389
5435
|
*/ function getBalance() {
|
|
5390
5436
|
return _async_to_generator(function() {
|
|
@@ -5427,8 +5473,11 @@ var EmbeddedWallet = /*#__PURE__*/ function() {
|
|
|
5427
5473
|
{
|
|
5428
5474
|
key: "signMultipleTransactions",
|
|
5429
5475
|
value: /**
|
|
5430
|
-
*
|
|
5431
|
-
*
|
|
5476
|
+
* To request signing of multiple PSBTs, you can use the `signMultipleTransactions` function.
|
|
5477
|
+
*
|
|
5478
|
+
* @param params - Object containing an array of PSBTs to sign, where each PSBT contains:
|
|
5479
|
+
* - `psbtBase64`: a valid psbt encoded in base64
|
|
5480
|
+
* - `inputsToSign`: an array of objects describing the address and index of input to sign
|
|
5432
5481
|
* @returns Promise resolving to signed PSBTs
|
|
5433
5482
|
* @throws {Error} If the wallet is read-only or private key is not available.
|
|
5434
5483
|
*/ function signMultipleTransactions(params) {
|
|
@@ -5485,7 +5534,7 @@ var EmbeddedWallet = /*#__PURE__*/ function() {
|
|
|
5485
5534
|
/**
|
|
5486
5535
|
* Simple largest-first coin selection algorithm.
|
|
5487
5536
|
* Selects UTXOs in descending order by value until target amount + fees is reached.
|
|
5488
|
-
*
|
|
5537
|
+
*
|
|
5489
5538
|
* @param utxos Available UTXOs
|
|
5490
5539
|
* @param targetAmount Amount needed in satoshis
|
|
5491
5540
|
* @param feeRate Fee rate in sat/vByte
|