diff --git a/README.md b/README.md index 5fda067..8534c1b 100644 --- a/README.md +++ b/README.md @@ -314,6 +314,19 @@ import {disconnect} from '@getalby/bitcoin-connect'; disconnect(); ``` +#### Get connector config + +Returns the saved configuration of the currently-connected connector (if connected) + +```ts +import {getConnectorConfig} from '@getalby/bitcoin-connect'; + +const connectorConfig = getConnectorConfig(); +if (connectorConfig) { + // can now access e.g. connectorConfig.connectorName +} +``` + #### Events ##### onConnected diff --git a/dev/vite/index.html b/dev/vite/index.html index e22ac92..2f81ed9 100644 --- a/dev/vite/index.html +++ b/dev/vite/index.html @@ -245,6 +245,8 @@

Pay an invoice

Make an invoice

+

Connector config

+

Try it yourself

Open devtools and use window.bitcoinConnectSandbox to access the @@ -258,6 +260,7 @@

Try it yourself

launchModal, launchPaymentModal, requestProvider, + getConnectorConfig, } from '../../src/index.ts'; const appName = localStorage.getItem('app-name'); @@ -386,6 +389,12 @@

Try it yourself

} }); + document + .getElementById('get-connector-config') + .addEventListener('click', async () => { + alert(JSON.stringify(getConnectorConfig(), null, 2)); + }); + document.addEventListener('bc:onpaid', (e) => console.log('PAID!', e));