Resolve "fix(Blockchain): Add token support for BlockchainInMemory"

This commit is contained in:
2025-11-03 07:47:15 +00:00
committed by Emergent Reasons
parent b1ef3f1f8b
commit 2957a6d559
@@ -156,11 +156,19 @@ export class BlockchainInMemory extends BaseBlockchain<BlockHeightPayload> {
);
}
// Check if the transaction has a mempool input, if there is one, we need to set the height to -1 to indicate that it uses an unconfirmed input
const hasMempoolInput = tx.getInputs().some((input) => {
const tx = this.transactions.get(binToHex(input.outpointTransactionHash));
if (!tx) return false;
return tx.height <= 0;
});
// Add the transaction.
this.addTransaction({
hash: tx.toHash(),
transaction: tx,
height: 0,
height: hasMempoolInput ? -1 : 0,
});
// Notify our address and transaction subscribers.
@@ -330,10 +338,11 @@ export class BlockchainInMemory extends BaseBlockchain<BlockHeightPayload> {
for (const tx of this.transactions.values()) {
tx.transaction.getOutputs().forEach((output, outpointIndex) => {
const utxo: BlockchainUTXO = {
height: 0,
height: tx.height,
utxo: UTXO.from(new Outpoint(tx.hash.toBytes(), outpointIndex), {
valueSatoshis: output.valueSatoshis,
lockingBytecode: output.lockingBytecode,
token: output.token,
}),
};
utxoMap.set(`${tx.hash.toHex()}:${outpointIndex}`, utxo);