Skip to content

Commit

Permalink
COINBASE_CFM_COUNT
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder83singh committed Jun 15, 2022
1 parent 3236b3a commit 15e71cb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {log, FlowLogger} from "./utils/logger";
import {Wallet, Storage, kaspacore, CONFIRMATION_COUNT} from "./wallet/wallet";
import {Wallet, Storage, kaspacore, CONFIRMATION_COUNT, COINBASE_CFM_COUNT} from "./wallet/wallet";
import {initKaspaFramework} from './wallet/initKaspaFramework';
import {EventTargetImpl} from './wallet/event-target-impl';
import * as helper from './utils/helper';

export {CONFIRMATION_COUNT};
export {CONFIRMATION_COUNT, COINBASE_CFM_COUNT};
export {Wallet, initKaspaFramework, log, EventTargetImpl, helper, Storage, FlowLogger, kaspacore}
5 changes: 4 additions & 1 deletion wallet/tx-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface TXStoreItem{
note?:string;
tx?:any,
myAddress?:boolean,
isCoinbase:boolean,
isMoved?:boolean
}

Expand Down Expand Up @@ -70,7 +71,8 @@ export class TXStore{
address,
blueScore:utxo.blockDaaScore,
tx:false,//TODO
isMoved:true
isMoved:true,
isCoinbase:false
};
}
this.emitTx(dbItem);
Expand All @@ -86,6 +88,7 @@ export class TXStore{
amount: utxo.amount,
address,
blueScore:utxo.blockDaaScore,
isCoinbase:utxo.isCoinbase,
tx:false//TODO
};
this.add(item);
Expand Down
5 changes: 3 additions & 2 deletions wallet/utxo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {EventTargetImpl} from './event-target-impl';
const KAS = helper.KAS;
export {UnspentOutput};
export const CONFIRMATION_COUNT = 10;
export const COINBASE_CFM_COUNT = 100;

let seq = 0;
export class UtxoSet extends EventTargetImpl {
Expand Down Expand Up @@ -58,7 +59,7 @@ export class UtxoSet extends EventTargetImpl {
//console.log("utxoInUse", {utxoInUse, alreadyHaveIt})
if (!utxoInUse && !alreadyHaveIt /*&& utxo.isSpendable*/ ) {
utxoIds.push(utxoId);
let confirmed = (blueScore-utxo.blockDaaScore>=CONFIRMATION_COUNT);
let confirmed = (blueScore-utxo.blockDaaScore>= (utxo.isCoinbase? COINBASE_CFM_COUNT : CONFIRMATION_COUNT));
let unspentOutput = new UnspentOutput({
txid: utxo.transactionId,
address,
Expand Down Expand Up @@ -170,7 +171,7 @@ export class UtxoSet extends EventTargetImpl {
updateUtxoBalance(): void {
const {blueScore} = this.wallet;
[...this.utxos.pending.values()].forEach(utxo=>{
if(blueScore-utxo.blockDaaScore < CONFIRMATION_COUNT)
if(blueScore-utxo.blockDaaScore < (utxo.isCoinbase? COINBASE_CFM_COUNT : CONFIRMATION_COUNT))
return
this.utxos.pending.delete(utxo.txId+utxo.outputIndex);
this.wallet.adjustBalance(false, -utxo.satoshis, false);
Expand Down
7 changes: 4 additions & 3 deletions wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {

import {CreateLogger, Logger} from '../utils/logger';
import {AddressManager} from './address-manager';
import {UnspentOutput, UtxoSet, CONFIRMATION_COUNT} from './utxo';
import {UnspentOutput, UtxoSet, CONFIRMATION_COUNT, COINBASE_CFM_COUNT} from './utxo';
import {TXStore} from './tx-store';
import {CacheStore} from './cache-store';
import {KaspaAPI, ApiError} from './api';
Expand All @@ -35,7 +35,7 @@ const SompiPerKaspa = 100_000_000
// MaxSompi is the maximum transaction amount allowed in sompi.
const MaxSompi = 21_000_000 * SompiPerKaspa

export {kaspacore, COMPOUND_UTXO_MAX_COUNT, CONFIRMATION_COUNT};
export {kaspacore, COMPOUND_UTXO_MAX_COUNT, CONFIRMATION_COUNT, COINBASE_CFM_COUNT};

/** Class representing an HDWallet with derivable child addresses */
class Wallet extends EventTargetImpl {
Expand Down Expand Up @@ -1125,7 +1125,8 @@ class Wallet extends EventTargetImpl {
in:false, ts, id:txid, amount, address:toAddr, note,
blueScore: this.blueScore,
tx:rpcTX.transaction,
myAddress: this.addressManager.isOur(toAddr)
myAddress: this.addressManager.isOur(toAddr),
isCoinbase: false
})
this.updateDebugInfo();
this.emitCache()
Expand Down

0 comments on commit 15e71cb

Please sign in to comment.