Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ You can use Bitcoin Connect without any build tools:

```html
<script type="module">
import {launchModal} from 'https://esm.sh/@getalby/bitcoin-connect@^3.11.0'; // jsdelivr.net, skypack.dev also work
import {launchModal} from 'https://esm.sh/@getalby/bitcoin-connect@^3.12.0'; // jsdelivr.net, skypack.dev also work

// use Bitcoin connect API normally...
launchModal();

// or if you just want access to the web components:
import 'https://esm.sh/@getalby/bitcoin-connect@^3.11.0';
import 'https://esm.sh/@getalby/bitcoin-connect@^3.12.0';
</script>

<!-- Bitcoin Connect components are now available -->
Expand Down Expand Up @@ -356,6 +356,16 @@ if (connectorConfig) {
}
```

#### Refresh balance

Programmatically trigger a balance refresh for all `<bc-balance>` components on the page. Useful after making a payment or receiving funds to update the displayed balance.

```ts
import {refreshBalance} from '@getalby/bitcoin-connect';

refreshBalance();
```

#### Events

##### onConnected
Expand Down
2 changes: 1 addition & 1 deletion demos/html/bc-api-usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h1>Programmatic Access Demo</h1>
launchPaymentModal,
requestProvider,
disconnect,
} from 'https://esm.sh/@getalby/bitcoin-connect@^3.11.0';
} from 'https://esm.sh/@getalby/bitcoin-connect@^3.12.0';
import {LightningAddress} from 'https://esm.sh/@getalby/lightning-tools@^5.2.0';

// Initialize Bitcoin Connect with your app name
Expand Down
2 changes: 1 addition & 1 deletion demos/html/bc-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
<title>bc-button Demo</title>
<script type="module">
import {onConnected} from 'https://esm.sh/@getalby/bitcoin-connect@^3.11.0';
import {onConnected} from 'https://esm.sh/@getalby/bitcoin-connect@^3.12.0';
onConnected((provider) => {
console.log('Connected with provider', provider);
});
Expand Down
2 changes: 1 addition & 1 deletion demos/html/bc-pay-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<script type="module">
// Import necessary modules from esm.sh CDN
import {init} from 'https://esm.sh/@getalby/bitcoin-connect@^3.11.0';
import {init} from 'https://esm.sh/@getalby/bitcoin-connect@^3.12.0';
import {LightningAddress} from 'https://esm.sh/@getalby/lightning-tools@^5.2.0';

// Initialize Bitcoin Connect with your app name
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@getalby/bitcoin-connect",
"version": "3.11.5",
"version": "3.12.0",
"description": "Web components to connect to a lightning wallet and power a website with WebLN",
"type": "module",
"source": "src/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@getalby/bitcoin-connect-react",
"version": "3.11.5",
"version": "3.12.0",
"type": "module",
"source": "src/index.ts",
"main": "./dist/index.cjs",
Expand Down Expand Up @@ -28,7 +28,7 @@
"dts": "dts-bundle-generator dist/index.d.ts -o dist/bundle.d.ts --project tsconfig.dts.json --no-check"
},
"dependencies": {
"@getalby/bitcoin-connect": "^3.11.5"
"@getalby/bitcoin-connect": "^3.12.0"
},
"devDependencies": {
"@types/react": "^18.2.21",
Expand Down
1 change: 1 addition & 0 deletions react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export {
onModalOpened,
onModalClosed,
getConnectorConfig,
refreshBalance,
WebLNProviders,
PaymentMethods,
} from '@getalby/bitcoin-connect';
8 changes: 4 additions & 4 deletions react/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1018,10 +1018,10 @@
"@babel/helper-validator-identifier" "^7.22.5"
to-fast-properties "^2.0.0"

"@getalby/bitcoin-connect@^3.11.5":
version "3.11.5"
resolved "https://registry.yarnpkg.com/@getalby/bitcoin-connect/-/bitcoin-connect-3.11.5.tgz#9ae3a467e28cb3288bff576c227d90d585e60d34"
integrity sha512-8HLJyBoh/uBdho5QV9XxPx+A6d2rXHyJK7hvL2FvKjBZrtPK3Zylg4V8mkrUM0OM96Cz7tCemJM/Xi5tEBqcUg==
"@getalby/bitcoin-connect@^3.12.0":
version "3.12.0"
resolved "https://registry.yarnpkg.com/@getalby/bitcoin-connect/-/bitcoin-connect-3.12.0.tgz#146ac63e1b2f12c21973ab9236c6f1db81c18c52"
integrity sha512-0Zc3BjNDZOQv/zXZHxpLpE2ZO0NKJ85NT0WWjkhvDID4ZWhO9iNfzTZ4AFjT4qAWPKOxnad+F1du+cRHwZ8KEQ==
dependencies:
"@getalby/lightning-tools" "^6.0.0"
"@getalby/sdk" "^6.0.2"
Expand Down
8 changes: 8 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ export function init(config: BitcoinConnectConfig = {}) {
store.getState().setBitcoinConnectConfig(config);
}

/**
* Refresh the balance of the connected wallet
*/

export function refreshBalance() {
window.dispatchEvent(new CustomEvent('bc:balancerefresh'));
}

/**
* Programmatically launch the Bitcoin Connect modal
*/
Expand Down
4 changes: 4 additions & 0 deletions src/components/bc-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export class Balance extends withTwind()(BitcoinConnectElement) {

this._loadBalance();

window.addEventListener('bc:balancerefresh', () => {
this._loadBalance();
});

this._selectedCurrency = store.getState().currency;
store.subscribe((currentState, prevState) => {
this._selectedCurrency = currentState.currency;
Expand Down