Skip to content

Commit

Permalink
docs: add error handling suggestion to the README of the btc lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ShookLyngs committed Aug 8, 2024
1 parent d991cf5 commit ab41f6f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/btc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ yarn add @rgbpp-sdk/btc
$ pnpm add @rgbpp-sdk/btc
```

## Transaction
## Transactions

### Transfer BTC from a `P2WPKH` address

Expand Down Expand Up @@ -249,6 +249,22 @@ const psbt = await sendRbf({
});
```

## Errors

### Visit context of the TxBuildError

When you catch a `TxBuildError` error after calling the BTC Builder APIs (`sendBtc`, `sendUtxos`, etc), you can access the `e.context` object for error tracing, where it should contain a `tx` property that is a `TxBuilder` object:

```typescript
try {
await sendBtc({ ... });
} catch (e) {
if (e instanceof TxBuildError) {
console.log(e.context.tx); // TxBuilder object for error tracing
}
}
```

## Types

### Transaction
Expand Down

0 comments on commit ab41f6f

Please sign in to comment.