Skip to content

Commit

Permalink
Upgrade cashu-ts lib, improved zaps (fixed)
Browse files Browse the repository at this point in the history
  • Loading branch information
minibits-cash committed Jan 31, 2024
1 parent 8015676 commit 92a2272
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minibits_wallet",
"version": "0.1.5-beta.27",
"version": "0.1.5-beta.28",
"private": true,
"scripts": {
"android:clean": "cd android && ./gradlew clean",
Expand Down
6 changes: 2 additions & 4 deletions src/models/WalletProfileStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Instance, SnapshotOut, types, flow} from 'mobx-state-tree'
import {KeyChain, MinibitsClient, NostrClient, Wallet} from '../services'
import { UnsignedEvent as NostrUnsignedEvent } from 'nostr-tools/core'
import {KeyChain, MinibitsClient, NostrClient, NostrUnsignedEvent, Wallet} from '../services'
import {log} from '../services/logService'
import { Err } from '../utils/AppError'
import { getRandomUsername } from '../utils/usernames'
Expand Down Expand Up @@ -53,8 +52,7 @@ export const WalletProfileStoreModel = types
name,
picture,
nip05,
}),
created_at: Math.floor(Date.now() / 1000)
}),
}

const rootStore = getRootStore(self)
Expand Down
6 changes: 2 additions & 4 deletions src/screens/SendScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ import {
import {TransactionStatus, Transaction} from '../models/Transaction'
import {useStores} from '../models'
import {useHeader} from '../utils/useHeader'
import {Wallet, NostrClient} from '../services'
import { UnsignedEvent as NostrUnsignedEvent } from 'nostr-tools/core'
import {NostrClient, NostrProfile, NostrUnsignedEvent, Wallet} from '../services'
import {log} from '../services/logService'
import AppError, {Err} from '../utils/AppError'
import {translate} from '../i18n'
Expand Down Expand Up @@ -398,8 +397,7 @@ export const SendScreen: FC<WalletStackScreenProps<'Send'>> = observer(
kind: 4,
pubkey: senderPubkey,
tags: [['p', receiverPubkey as string], ['from', walletProfileStore.nip05]],
content: encryptedContent,
created_at: Math.floor(Date.now() / 1000)
content: encryptedContent,
}

const sentEvent: Event | undefined = await NostrClient.publish(
Expand Down
6 changes: 2 additions & 4 deletions src/screens/TopupScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import {
import {TransactionStatus, Transaction} from '../models/Transaction'
import {useStores} from '../models'
import {useHeader} from '../utils/useHeader'
import {NostrClient, NostrProfile, Wallet} from '../services'
import { UnsignedEvent as NostrUnsignedEvent } from 'nostr-tools/core'
import {NostrClient, NostrProfile, NostrUnsignedEvent, Wallet} from '../services'
import {log} from '../services/logService'
import AppError, { Err } from '../utils/AppError'

Expand Down Expand Up @@ -388,8 +387,7 @@ export const TopupScreen: FC<WalletStackScreenProps<'Topup'>> = observer(
kind: 4,
pubkey: senderPubkey,
tags: [['p', receiverPubkey as string], ['from', walletProfileStore.nip05]],
content: encryptedContent,
created_at: Math.floor(Date.now() / 1000)
content: encryptedContent,
}

const sentEvent: Event | undefined = await NostrClient.publish(
Expand Down
10 changes: 4 additions & 6 deletions src/services/keyChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import * as _Keychain from 'react-native-keychain'
import AppError, {Err} from '../utils/AppError'
import QuickCrypto from 'react-native-quick-crypto'
import { generateNewMnemonic } from '@cashu/cashu-ts'
import { generateSecretKey, getPublicKey } from 'nostr-tools/pure'
import { bytesToHex } from '@noble/hashes/utils'
import {btoa, atob, fromByteArray} from 'react-native-quick-base64'
import { generatePrivateKey, getPublicKey } from 'nostr-tools'
import {btoa, fromByteArray} from 'react-native-quick-base64'
import {log} from './logService'


Expand Down Expand Up @@ -213,9 +212,8 @@ const removeSeed = async function (): Promise<boolean> {

const generateNostrKeyPair = function () {
try {
const privateKeyUint = generateSecretKey() // uintarr
const publicKey = getPublicKey(privateKeyUint) // hex
const privateKey = bytesToHex(privateKeyUint) // hex
const privateKey = generatePrivateKey() // hex string
const publicKey = getPublicKey(privateKey)

log.trace('New HEX Nostr keypair created:', publicKey, privateKey)

Expand Down
2 changes: 1 addition & 1 deletion src/services/nostrService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export {
UnsignedEvent as NostrUnsignedEvent,
} from 'nostr-tools'

// refresh

export type NostrProfile = {
pubkey: string
npub: string
Expand Down

0 comments on commit 92a2272

Please sign in to comment.