Skip to content

Commit ee30e52

Browse files
Alex-WernerCofresi
authored andcommitted
Feat : Transaction.isSimpleTransaction (#114)
* Feat : Transaction.isSimpleTransaction + tests * Doc : Added Transaction.SimpleTransaction to doc * Doc : Apply requested change * chore(package): Bump version to 0.17.0 * bump patch version * update package lock
1 parent 0aa526b commit ee30e52

File tree

5 files changed

+129
-8014
lines changed

5 files changed

+129
-8014
lines changed

docs/transaction.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,11 @@ console.log(transaction.getLockTime());
175175
// output similar to: Sun Nov 30 2025 00:00:00 GMT-0300 (ART)
176176
```
177177

178+
## Simple Transaction
179+
180+
Since v0.13, simple transactions (having no more than 4 inputs), are entitled to an auto Instant Send upgrade (if mempool size is less than 10% full).
181+
182+
A method `isSimpleTransaction()` will simplify that verification for you.
183+
178184
## Upcoming changes
179185
We're debating an API for Merge Avoidance, CoinJoin, Smart contracts, CoinSwap, and Stealth Addresses. We're expecting to have all of them by some time in 2015. Payment channel creation is available in the [dashcore-channel](https://github.com/dashevo/dashcore-channel) module.

lib/transaction/transaction.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function Transaction(serialized) {
6464

6565
var CURRENT_VERSION = 3;
6666
var SPECIAL_TRANSACTION_ACTIVATION_VERSION = 3;
67+
var SIMPLE_TRANSACTIONS_MAX_INPUTS = 4;
6768
var DEFAULT_NLOCKTIME = 0;
6869
var MAX_BLOCK_SIZE = 1000000;
6970

@@ -1301,6 +1302,15 @@ Transaction.prototype.enableRBF = function() {
13011302
return this;
13021303
};
13031304

1305+
/**
1306+
* Returns true if this transaction is qualified to be a simple transaction to the network (<= 4 inputs).
1307+
* @returns {boolean}
1308+
*/
1309+
Transaction.prototype.isSimpleTransaction = function() {
1310+
return this.inputs.length <= SIMPLE_TRANSACTIONS_MAX_INPUTS;
1311+
};
1312+
1313+
13041314
/* DIP2 special transaction methods */
13051315

13061316
/**

0 commit comments

Comments
 (0)