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

feat: configurable on-chain confirmations target #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions class/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,18 +325,19 @@ export class User {
}

/**
* User's onchain txs that are >= 3 confs
* User's onchain txs that are >= configured target confirmations
* Queries bitcoind RPC.
*
* @returns {Promise<Array>}
*/
async getTxs() {
const addr = await this.getOrGenerateAddress();
const targetConfirmations = config.bitcoin.confirmations;
let txs = await this._listtransactions();
txs = txs.result;
let result = [];
for (let tx of txs) {
if (tx.confirmations >= 3 && tx.address === addr && tx.category === 'receive') {
if (tx.confirmations >= targetConfirmations && tx.address === addr && tx.category === 'receive') {
tx.type = 'bitcoind_tx';
result.push(tx);
}
Expand Down Expand Up @@ -461,17 +462,18 @@ export class User {
}

/**
* Returning onchain txs for user's address that are less than 3 confs
* Returning onchain txs for user's address that are less than configured target confirmations
*
* @returns {Promise<Array>}
*/
async getPendingTxs() {
const addr = await this.getOrGenerateAddress();
const targetConfirmations = config.bitcoin.confirmations;
let txs = await this._listtransactions();
txs = txs.result;
let result = [];
for (let tx of txs) {
if (tx.confirmations < 3 && tx.address === addr && tx.category === 'receive') {
if (tx.confirmations < targetConfirmations && tx.address === addr && tx.category === 'receive') {
result.push(tx);
}
}
Expand Down
3 changes: 3 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ let config = {
url: '1.1.1.1:10009',
password: '',
},
bitcoin: {
confirmations: 3,
},
};

if (process.env.CONFIG) {
Expand Down