Skip to content
Closed
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
3 changes: 1 addition & 2 deletions react/react-bitcoin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"@reown/appkit-adapter-bitcoin": "1.7.3",
"bitcoinjs-lib": "^6.1.7",
"react": "19.0.0",
"react-dom": "19.0.0",
"vite-plugin-node-polyfills": "^0.23.0"
"react-dom": "19.0.0"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
Expand Down
15 changes: 8 additions & 7 deletions react/react-bitcoin/src/components/ActionButtonList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useDisconnect, useAppKit, useAppKitNetwork, useAppKitProvider, useAppKitAccount } from '@reown/appkit/react'
import type { BitcoinConnector } from '@reown/appkit-adapter-bitcoin'
import { networks } from '../config'
import { createPSBT, getBalance } from '../utils/BitcoinUtil';

interface ActionButtonListProps {
sendSignPSBT: (hash: string ) => void;
Expand Down Expand Up @@ -55,10 +54,12 @@ export const ActionButtonList = ({ sendSignPSBT, sendSignMsg, sendSendTx, sendBa
// function to sign a PSBT
const handleSignPSBT = async () => {
if (!walletProvider || !address || !caipNetwork) throw Error('user is disconnected');
const amount = 10000;
const recipientAddress = address;

const params = await createPSBT(caipNetwork, amount, address, recipientAddress);
const params = {
broadcast: false,
psbt: "",
signInputs: []
}

params.broadcast = false // change to true to broadcast the tx

Expand All @@ -69,15 +70,15 @@ export const ActionButtonList = ({ sendSignPSBT, sendSignMsg, sendSendTx, sendBa
const handleGetBalance = async () => {
if (!walletProvider || !address || !caipNetwork) throw Error('user is disconnected');

const balance = await getBalance(caipNetwork, address);
sendBalance(balance.toString() );

sendBalance('0');
}

const handleGetPublicKey = async () => {
if (!walletProvider || !address || !caipNetwork) throw Error('user is disconnected');

const bip122Account = allAccounts?.find(a => a.address === address)
let publicKey = bip122Account?.publicKey || ""
const publicKey = bip122Account?.publicKey || ""

sendPublicKey(publicKey)
}
Expand Down
4 changes: 1 addition & 3 deletions react/react-bitcoin/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Buffer } from 'buffer'

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App'

// Make Buffer available globally
window.Buffer = Buffer

createRoot(document.getElementById('root')!).render(
<StrictMode>
Expand Down
6 changes: 2 additions & 4 deletions react/react-bitcoin/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), nodePolyfills()],
plugins: [react()],
define: {
'process.env': {},
'window.ethereum': 'undefined'
'process.env': {}
},
})