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
Wallet's 'confirmed' doesn't work #570
Comments
Hi @AlesTsurko thanks for checking out bcoin! The main issue here is that you sorta have created two wallets. The first is instantiated by the In my version, I removed the second wallet, and then also included a For more info on the client object, check out http://bcoin.io/api-docs/#wallet. I also switched SPV to Full Node and testnet to regtest, so I could generate blocks and test teh confirmations :-) but that shouldn't matter. I agree its weird that your script doesn't work -- the wallet object should catch the const bcoin = require('bcoin');
bcoin.set('regtest');
const node = new bcoin.node.FullNode({
config: true,
argv: true,
env: true,
logFile: true,
logConsole: true,
logLevel: 'debug',
db: 'leveldb',
memory: false,
persistent: true,
workers: true,
listen: true,
loader: require,
network: 'regtest'
});
// Temporary hack
if (!node.has('walletdb')) {
const plugin = require('../bcoin/lib/wallet/plugin');
node.use(plugin);
}
process.on('unhandledRejection', (err, promise) => {
throw err;
});
const {WalletClient} = require('bclient');
const {Network} = require('bcoin');
const network = Network.get('regtest');
const walletOptions = {
network: network.type,
port: network.walletPort,
apiKey: 'api-key'
}
const walletClient = new WalletClient(walletOptions);
const id = 'primary'; // or whatever your wallet name is
const wallet = walletClient.wallet(id);
(async () => {
await node.ensure();
await node.open();
await node.connect();
await walletClient.open();
await wallet.open();
// const wallet = await walletdb.create();
let addr = await wallet.createAddress('default');
addr = addr['address'];
console.log('Created wallet with address %s', addr);
// Add our address to the spv filter.
node.pool.watchAddress(addr);
node.startSync();
node.on('tx', async (tx) => {
console.log('------ New tx. Adding to walletdb...' + tx);
console.log(tx);
});
node.chain.on('block', async (block) => {
console.log('------ block', block);
});
wallet.on('confirmed', (tx) => {
console.log('---------------- confirmed', tx);
});
})().catch((err) => {
console.error(err.stack);
process.exit(1);
}); |
Thanks very much, @pinheadmz!
|
Hi Ales, ok -- so, the wallet events are accessible, and they are catchable like this:
What's interesting is I can't get |
@AlesTsurko I think you can close this issue unless you have any further questions? Thanks! |
Thanks! |
Hi.
I'm trying to catch
'confirmed'
event for my wallet on SPV node.I found that this event emits only for the first confirmation. But for me it doesn't work even in that way. I'm almost sure that I'm doing something wrong, but I didn't found any help for this neither in examples nor guides.
Here's how I'm trying to do this:
Please note that this issue isn't duplicate of #419 — I can't get even a single notification.
The text was updated successfully, but these errors were encountered: