Skip to content
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
3 changes: 2 additions & 1 deletion chain_params.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"defaultColdStakingAddress": "SdgQDpS8jDRJDX8yK8m9KnTMarsE84zdsy",
"stakeSplitTarget": 50000000000,
"mnReward": 600000000,
"defaultStartingShieldBlock": 4190531
"defaultStartingShieldBlock": 4190531,
"confirmsForSaving": 20
},
"testnet": {
"name": "testnet",
Expand Down
3 changes: 2 additions & 1 deletion chain_params.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"defaultColdStakingAddress": "SdgQDpS8jDRJDX8yK8m9KnTMarsE84zdsy",
"stakeSplitTarget": 50000000000,
"mnReward": 600000000,
"defaultStartingShieldBlock": 4190531
"defaultStartingShieldBlock": 4190531,
"confirmsForSaving": 20
},
"testnet": {
"name": "testnet",
Expand Down
4 changes: 4 additions & 0 deletions scripts/transaction_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ export class TransactionBuilder {
}
}

setTime(time) {
this.#transaction.blockTime = Math.floor(time.getTime() / 1000);
}

build() {
const tx = this.#transaction;
if (tx && !tx.vin.length) {
Expand Down
9 changes: 8 additions & 1 deletion scripts/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ export class Wallet {
changeAddress = '',
returnAddress = '',
memo = '',
time = new Date(),
} = {}
) {
let balance;
Expand Down Expand Up @@ -1276,6 +1277,7 @@ export class Wallet {
}
}
}
transactionBuilder.setTime(time);
return transactionBuilder.build();
}

Expand Down Expand Up @@ -1410,7 +1412,12 @@ export class Wallet {
await this.#shield?.finalizeTransaction(transaction.txid);
}

if (!skipDatabase) {
if (
!skipDatabase &&
transaction.blockHeight !== -1 &&
this.#lastProcessedBlock - transaction.blockHeight >
cChainParams.current.confirmsForSaving
) {
const db = await Database.getInstance();
await db.storeTx(transaction, this.getKeyToExport());
}
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/wallet/transactions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ describe('Wallet transaction tests', () => {
0.05 * 10 ** 8,
{ useShieldInputs: true }
);
// Reset blocktime for tests
tx.blockTime = -1;
expect(tx).toStrictEqual(
new Transaction({
version: 3,
Expand All @@ -319,6 +321,8 @@ describe('Wallet transaction tests', () => {
const tx = wallet.createTransaction(addr, 0.05 * 10 ** 8, {
useShieldInputs: true,
});
// Reset blocktime for tests
tx.blockTime = -1;
expect(tx).toStrictEqual(
new Transaction({
version: 3,
Expand Down
Loading