Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
docs: add btc_sendmany method (#295)
Browse files Browse the repository at this point in the history
* docs: add `btc_sendmany` method

* docs: rename parameter description

* chore: replace `Properties` with `Items` for arrays

* chore: rename `btc_sendmany` response name

* fix: rename `btc_sendTransaction` to `btc_sendmany`
  • Loading branch information
danroc authored Apr 29, 2024
1 parent 042caf7 commit c2507aa
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 4 deletions.
73 changes: 73 additions & 0 deletions docs/btc-methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# BTC Methods

Here we document the Bitcoin methods that an account Snap may implement to
support requests originated from dapps.

## btc_sendmany

This method is similar to the `sendmany` RPC method from Bitcoin Core, but its
parameters are passed in an object instead of an array, and are named in
camelCase. Also, dummy values aren't allowed.

### Parameters

- **Transaction intent (required)**
- Type: `object`
- Properties:
- `amounts`
- Description: A JSON object with recipient addresses and amounts.
- Type: `object`
- Properties:
- `[key]: string`: Address of the recipient
- `[value]: string`: Amount to send to the recipient in BTC
- `comment` (optional)
- Description: A comment.
- Type: `string`
- `subtractFeeFrom` (optional)
- Description: The fee will be equally deducted from the amount of each
selected address. Those recipients will receive less bitcoins than you
enter in their corresponding amount field. If no addresses are specified
here, the sender pays the fee.
- Type: `array`
- Items:
- Type: `string`
- `replaceable` (optional)
- Description: Allow this transaction to be replaced by a transaction
with higher fees via BIP 125.
- Type: `boolean`

### Returns

- **Transaction ID**
- Type: `object`
- Properties:
- `txid`
- Description: The transaction ID.
- Type: `string`

### Examples

**Request:**

```json
{
"method": "btc_sendmany",
"params": {
"amounts": {
"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl": "0.01",
"bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3": "0.02"
},
"comment": "testing",
"subtractFeeFrom": ["bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl"],
"replaceable": false
}
}
```

**Response:**

```json
{
"txid": "53de51e2fa75c3cfa51132865f7d430138b1cd92a8f5267ec836ec565b422969"
}
```
4 changes: 2 additions & 2 deletions docs/evm-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ Adds support to [`eth_sendTransaction`][eth-send-transaction].
- `accessList`:
- Description: EIP-2930 access list
- Type: `array`
- Properties:
- Items:
- Type: `object`
- Properties:
- `address`
- Type: `string`
- Pattern: `^0x[0-9a-fA-F]{40}$`
- `storageKeys`
- Type: `array`
- Properties:
- Items:
- Type: `string`
- Pattern: `^0x[0-9a-f]{64}$`
- `chainId`
Expand Down
4 changes: 2 additions & 2 deletions src/btc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const BtcP2wpkhAddressStruct = refine(
*/
export enum BtcMethod {
// General transaction methods
SendTransaction = 'btc_sendTransaction',
SendMany = 'btc_sendmany',
}

/**
Expand All @@ -45,7 +45,7 @@ export const BtcP2wpkhAccountStruct = object({
/**
* Account supported methods.
*/
methods: array(enums([`${BtcMethod.SendTransaction}`])),
methods: array(enums([`${BtcMethod.SendMany}`])),
});

export type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;

0 comments on commit c2507aa

Please sign in to comment.