Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribing to derived address #9

Open
emochka2007 opened this issue Mar 22, 2024 · 0 comments
Open

Subscribing to derived address #9

emochka2007 opened this issue Mar 22, 2024 · 0 comments

Comments

@emochka2007
Copy link

Hello, I would like to know - is there a way to subscribe to the events of the derived addresses?
When I was using main receive address, i was getting the events, but when i tried to send KAS to derived address, no events emitted.
Here i derive address with index

deriveAddress(index: number) {
        // const dType = deriveType === 'receive' ? 0 : 1;
        const dType = '0'
        const seedWallet = Wallet.fromMnemonic(KEYCHAIN_SEED, { network: 'kaspa', rpc: this.rpc })
        const privateKey = seedWallet.HDWallet.deriveChild(`m/44'/972/0'/${dType}'/${index}'`)
        const addressManager = new AddressManager(privateKey, 'kaspa')
        const newAddr = addressManager.getAddresses(1, 'receive')

        return {
            publicKey: newAddr[0].address,
            privateKey: addressManager.receiveAddress.keypairs[newAddr[0].address].toString(),
        }
    }

Here, I'm subscribing to the events.

 const wallet = Wallet.fromMnemonic(
            KEYCHAIN_SEED,
            { network: 'kaspa', rpc: this.rpc },
            {
                addressDiscoveryExtent: 1000,
            }
        )
        
  wallet.on('balance-update', balance => {
            this.logger.warn('BALANCE UPDATED')
            this.logger.debug(JSON.stringify(balance))
        }) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant