Skip to content

Commit 3a5e9d1

Browse files
committed
fix: consider locked node balance
1 parent 4aa0c07 commit 3a5e9d1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/core-rpc/client.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface CoreRpcAccountInfo {
88
balance: string;
99
/** Hex-prefixed binary blob. */
1010
balance_proof: string;
11+
locked: string;
1112
nonce: number;
1213
/** Hex-prefixed binary blob. */
1314
nonce_proof: string;
@@ -190,8 +191,8 @@ export class StacksCoreRpcClient {
190191
return nonce;
191192
}
192193

193-
async getAccountBalance(principal: string, indexBlockHash?: string): Promise<BigInt> {
194-
const account = await this.getAccount(principal, false, indexBlockHash);
194+
async getAccountBalance(principal: string): Promise<BigInt> {
195+
const account = await this.getAccount(principal);
195196
const balance = BigInt(account.balance);
196197
return balance;
197198
}

utils/src/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ async function printTopAccountBalances(count: number, blockHeight: number) {
8888
item.apiBalance = balance.balance;
8989
});
9090
const nodeBalances = addressBalances.map(async item => {
91-
const balance = await new StacksCoreRpcClient().getAccountBalance(
91+
const account = await new StacksCoreRpcClient().getAccount(
9292
item.address,
93+
false,
9394
blockInfo.index_block_hash.toString('hex')
9495
);
95-
item.nodeBalance = balance.valueOf();
96+
item.nodeBalance = BigInt(account.balance) + BigInt(account.locked);
9697
});
9798
await Promise.all(dbBalances.concat(nodeBalances));
9899

0 commit comments

Comments
 (0)