@waves/waves-transactions
Advanced tools
Comparing version
@@ -23,2 +23,9 @@ import { ICancelOrder, IOrder, TRANSACTION_TYPE, TTx, TTxParams } from './transactions'; | ||
/** | ||
* Verifies signature of transaction or order | ||
* @param obj | ||
* @param proofN - proof index. Takes first proof by default | ||
* @param publicKey - takes senderPublicKey by default | ||
*/ | ||
export declare function verify(obj: TTx | IOrder, proofN?: number, publicKey?: string): boolean; | ||
/** | ||
* Sends transaction to waves node | ||
@@ -25,0 +32,0 @@ * @param tx - transaction to send |
@@ -7,2 +7,4 @@ "use strict"; | ||
const axios_1 = __importDefault(require("axios")); | ||
const marshall_1 = require("@waves/marshall"); | ||
const waves_crypto_1 = require("@waves/waves-crypto"); | ||
const transactions_1 = require("./transactions"); | ||
@@ -21,3 +23,2 @@ const issue_1 = require("./transactions/issue"); | ||
const set_asset_script_1 = require("./transactions/set-asset-script"); | ||
const marshall_1 = require("@waves/marshall"); | ||
exports.txTypeMap = { | ||
@@ -58,2 +59,15 @@ [transactions_1.TRANSACTION_TYPE.ISSUE]: { sign: (x, seed) => issue_1.issue(x, seed) }, | ||
/** | ||
* Verifies signature of transaction or order | ||
* @param obj | ||
* @param proofN - proof index. Takes first proof by default | ||
* @param publicKey - takes senderPublicKey by default | ||
*/ | ||
function verify(obj, proofN = 0, publicKey) { | ||
publicKey = publicKey || obj.senderPublicKey; | ||
const bytes = serialize(obj); | ||
const signature = obj.version == null ? obj.signature : obj.proofs[proofN]; | ||
return waves_crypto_1.verifySignature(publicKey, bytes, signature); | ||
} | ||
exports.verify = verify; | ||
/** | ||
* Sends transaction to waves node | ||
@@ -60,0 +74,0 @@ * @param tx - transaction to send |
@@ -16,3 +16,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -19,0 +19,0 @@ }, |
@@ -19,3 +19,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -22,0 +22,0 @@ }, |
@@ -16,3 +16,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -19,0 +19,0 @@ }, |
@@ -26,3 +26,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -29,0 +29,0 @@ }, |
@@ -34,3 +34,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -37,0 +37,0 @@ }, |
@@ -19,3 +19,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -22,0 +22,0 @@ }, |
@@ -26,3 +26,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -29,0 +29,0 @@ }, |
@@ -22,3 +22,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -25,0 +25,0 @@ }, |
@@ -20,3 +20,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -23,0 +23,0 @@ }, |
@@ -20,3 +20,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -23,0 +23,0 @@ }, |
@@ -29,3 +29,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -32,0 +32,0 @@ }, |
@@ -257,3 +257,3 @@ import { TypelessDataEntry } from './transactions/data'; | ||
* 1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures. | ||
* 2. You want only to create tx, not to sign it. Therefore no seed is provided. | ||
* 2. You to create tx without proof. Therefore no seed is provided. | ||
*/ | ||
@@ -260,0 +260,0 @@ senderPublicKey?: string; |
@@ -6,16 +6,20 @@ import { IAliasParams, IAliasTransaction, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[IAliasTransaction]] as a second argument. | ||
* Also you can use already formed [[IAliasTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { alias } = require('waves-transactions') | ||
* const { alias } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
* const params = { | ||
* alias: 'MyNewAlias', | ||
* chainId: 'W', | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
* //fee: 100000, | ||
* //chainId: 'W', | ||
* } | ||
@@ -28,12 +32,12 @@ * | ||
* { | ||
* "id": "EjNehmfVkqDR6FeKBsrhrQX7kKrmG14QUiBQgjxDEVLJ", | ||
* "id": "3A88ZBfqvkx8tKLmkdpGZwCMVMsTZGF76LWiHFfJzMKR", | ||
* "type": 10, | ||
* "version": 2, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "alias": "MyNewAlias", | ||
* "fee": 100000, | ||
* "timestamp": 1549967848251, | ||
* "timestamp": 1550234087069, | ||
* "chainId": 87, | ||
* "proofs": [ | ||
* "56THgRHtxVoxoPxQxqhaU9yq5n4g5qnpErvnX6wKDwcKwVBVSUGoZuQ8P6j3scxTg72sosXXZVDUDVGRJjPwXPtN" | ||
* "2jKkgBtpzubyLaujVvXXi7DuorrKz8RFKShsLUm5Wq4h3JPzixwARtmef4WsqwYq165FPy8PUruAi8DMqrSmB12e" | ||
* ] | ||
@@ -40,0 +44,0 @@ * } |
@@ -6,10 +6,13 @@ import { IBurnTransaction, IBurnParams, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[IBurnTransaction]] as a second argument. | ||
* Also you can use already formed [[IBurnTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { burn } = require('waves-transactions') | ||
* const { burn } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
@@ -19,2 +22,3 @@ * const params = { | ||
* quantity: 100, | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
@@ -30,6 +34,6 @@ * //fee: 100000, | ||
* { | ||
* "id": "5FEXeovEfLVDyzyfW3qJ6YHnRFKEJX6tuNRVw5HNQYeR", | ||
* "id": "4x2dfA28S3Exh7oFi4Ed2NDH8CbrFkYUBdVJyYKaR1Gi", | ||
* "type": 6, | ||
* "version": 2, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "assetId": "4uK8i4ThRGbehENwa6MxyLtxAjAo1Rj9fduborGExarC", | ||
@@ -39,5 +43,5 @@ * "quantity": 100, | ||
* "fee": 100000, | ||
* "timestamp": 1549967848122, | ||
* "timestamp": 1550234086922, | ||
* "proofs": [ | ||
* "cNUxcZMmfYvXaSqnP782igoDHzd872txnC4rfQAB7PJwq5x9y7vYt6h47FdQGP7cLc9UFh86ojfsRUQTU2M4KNb" | ||
* "3YB9ewLmKS8TrNC8oGnsarNf8G9g2vnL7X7M55Zn9UsLji2tgB1TDXr9sgP4t1BGKcAR7vAjq3PayBde43SJCmgS" | ||
* ] | ||
@@ -44,0 +48,0 @@ * } |
@@ -6,13 +6,17 @@ import { ICancelLeaseTransaction, ICancelLeaseParams, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[ICancelLeaseTransaction]] as a second argument. | ||
* Also you can use already formed [[ICancelLeaseTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { cancelLease } = require('waves-transactions') | ||
* const { cancelLease } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
* const params = { | ||
* leaseId: '2fYhSNrXpyKgbtHzh5tnpvnQYuL7JpBFMBthPSGFrqqg', | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
@@ -28,12 +32,12 @@ * //fee: 100000, | ||
* { | ||
* "id": "78vCW4EBq8kksJJYzDHHy9cgBQaCzB1yuoZugdDTuKQ6", | ||
* "id": "C2VCffcn4bZjAi9rQp2LsS5ZqQhXTaVSy7neHtVxDD62", | ||
* "type": 9, | ||
* "version": 2, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "leaseId": "2fYhSNrXpyKgbtHzh5tnpvnQYuL7JpBFMBthPSGFrqqg", | ||
* "fee": 100000, | ||
* "timestamp": 1549967848146, | ||
* "timestamp": 1550234086949, | ||
* "chainId": 87, | ||
* "proofs": [ | ||
* "2FZ2Zh1BK9G6Ae6UY1dk8Mf7TNQDsQNRB8dKD9xUWPNpvJ6MPVzT82SGjrxJA1WfLN6bKq4KN4i7KW7osWvsPR22" | ||
* "4N7L5dRhqUsEXHGaMybM6Zi3zwsQUSCziJjcJ5q8AdeHfs3NZ6YK6ZFH4fKNWiUhXxzwWQX4NqsQBr8W6jsXoRpu" | ||
* ] | ||
@@ -40,0 +44,0 @@ * } |
@@ -11,10 +11,13 @@ /// <reference types="node" /> | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[IDataTransaction]] as a second argument. | ||
* Also you can use already formed [[IDataTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { data } = require('waves-transactions') | ||
* const { data } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
@@ -28,2 +31,3 @@ * const params = { | ||
* ], | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
@@ -38,10 +42,10 @@ * //fee: 100000 + bytes.length * 100000 | ||
* { | ||
* "id": "J3hMjJxPzMBtMGD2ZdsbxkDjwwbmrBbk1Z814u4qoUeA", | ||
* "id": "GKsw9rF8pTDMmY9YzESnwsjUJvzK6stg8RjF21EnTqLJ", | ||
* "type": 12, | ||
* "version": 1, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "fee": 100000, | ||
* "timestamp": 1549967848166, | ||
* "timestamp": 1550234086973, | ||
* "proofs": [ | ||
* "2uxt6KGQsFbF3P3mVsci4HcSx4gk3kBu5iSyMrQ5kq4VboWG1eHjkm6TFrotuqjV4qm1t84bqfNpngNK7ezdV7vr" | ||
* "2gQM99Vz8NNZw7UxYTTPtf3CLgksYQEpgpFUf85sFNQtj5cEoCLupQ7ewkVTVPk3qBBTwzJik2hnZNwijGyL7XBr" | ||
* ], | ||
@@ -48,0 +52,0 @@ * "data": [ |
@@ -6,10 +6,13 @@ import { IIssueTransaction, IIssueParams, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[IIssueTransaction]] as a second argument. | ||
* Also you can use already formed [[IIssueTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { issue } = require('waves-transactions') | ||
* const { issue } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
@@ -20,2 +23,3 @@ * const params = { | ||
* quantity: 1000000, | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //reissuable: false | ||
@@ -33,6 +37,6 @@ * //decimals: 8 | ||
* { | ||
* "id": "CGDhE2cQH6BsFxCSvjymd1nQGUCAGCHWCjdsWovZyB5R", | ||
* "id": "EnGVfcJyQYqYZWWembyVjhs6EnPP1rqtCehF17UaSvhm", | ||
* "type": 3, | ||
* "version": 2, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "name": "SCAM TOKEN", | ||
@@ -44,6 +48,6 @@ * "description": "Awesome token that will tokenize tokenization tokenized", | ||
* "fee": 100000000, | ||
* "timestamp": 1549967848182, | ||
* "timestamp": 1550234086993, | ||
* "chainId": 87, | ||
* "proofs": [ | ||
* "4VdJp2SPUu476r3dfCxkPXBgv5mcJKncRkckdxq6hL4y1E8fSNYQLS7CECEcrU1Di7Lwgv8qw1dWqt9H2kLzModL" | ||
* "2eiazUfrjQAfvauK6yo2NRD4U7s8FqxuKPjkDMQX8NkrizCa88SwJferZ9pSkqFz6cyuCS9oh7zYzwWUFYymyriR" | ||
* ] | ||
@@ -50,0 +54,0 @@ * } |
@@ -6,10 +6,13 @@ import { ILeaseTransaction, ILeaseParams, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[ILeaseTransaction]] as a second argument. | ||
* Also you can use already formed [[ILeaseTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { lease } = require('waves-transactions') | ||
* const { lease } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
@@ -19,2 +22,3 @@ * const params = { | ||
* recipient: '3P23fi1qfVw6RVDn4CH2a5nNouEtWNQ4THs', | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
@@ -29,12 +33,12 @@ * //fee: 100000, | ||
* { | ||
* "id": "BZHYPjKyzQa99u3vE6XqMLn6wFtrAoUYcKv8Adai6MV5", | ||
* "id": "53CNuASQwYBayGkrT58YZF3PAN3Hxhb7Mj9aH2zef4h7", | ||
* "type": 8, | ||
* "version": 2, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "amount": 100, | ||
* "recipient": "3P23fi1qfVw6RVDn4CH2a5nNouEtWNQ4THs", | ||
* "fee": 100000, | ||
* "timestamp": 1549967848198, | ||
* "timestamp": 1550234087013, | ||
* "proofs": [ | ||
* "EHrzWxMtfuNCqJWTWA7yrdYXyXQAn5QDqycj8ptG2mk62wYfikXh5QqYZ2Q1PHHsdAwGwKxGhZhjsiav7Wsa4SD" | ||
* "2gJe7GsCVBC282RnFG1xJE7uRHy9WKLdaGwGMMPKMoNU5PznGr4tJv5dYba8yWNCx9VaJB7n4hyBBaC6UCiCB68Z" | ||
* ] | ||
@@ -41,0 +45,0 @@ * } |
@@ -6,10 +6,13 @@ import { IMassTransferTransaction, IMassTransferParams, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[IMassTransferTransaction]] as a second argument. | ||
* Also you can use already formed [[IMassTransferTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { massTransfer } = require('waves-transactions') | ||
* const { massTransfer } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
@@ -27,2 +30,3 @@ * const params = { | ||
* ], | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
@@ -37,6 +41,6 @@ * //fee: 100000 + transfers.length * 50000, | ||
* { | ||
* "id": "9dQmFietocP3rtcaZzWFnRiWE5CWxFeRtvHfQGGVkcxq", | ||
* "id": "EuqiT5wGFrRrWgdTRFFD9PFSQyTChcTaDgBE3bJ2AY64", | ||
* "type": 11, | ||
* "version": 1, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "transfers": [ | ||
@@ -53,6 +57,6 @@ * { | ||
* "fee": 200000, | ||
* "timestamp": 1549967848212, | ||
* "timestamp": 1550234087029, | ||
* "attachment": "", | ||
* "proofs": [ | ||
* "5WigmFrtxfHGXjL9vtvqkFJE1jEuPt5kUNZEUfyXRfAkVRidvkzUcEeEsbEtJuEu9g5gcTYxAU6LHyZHYqaazXnA" | ||
* "53sUY5RyrNf5xB3vNNBwKn6gPXdHRRCbnnWrSD7oDhj4CbxUAq56zRmwULBAAzjAyva9fyLssgCqKnus69T3MpJF" | ||
* ] | ||
@@ -59,0 +63,0 @@ * } |
@@ -6,10 +6,13 @@ import { IReissueTransaction, IReissueParams, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[IReissueTransaction]] as a second argument. | ||
* Also you can use already formed [[IReissueTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { reissue } = require('waves-transactions') | ||
* const { reissue } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
@@ -20,2 +23,3 @@ * const params = { | ||
* reissuable: false, | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
@@ -31,6 +35,6 @@ * //fee: 100000000, | ||
* { | ||
* "id": "GQ4R4SPSMJQMybtjfNDW6FBkWE6suferTW5u2ABcVqyk", | ||
* "id": "2tkJu2La2jXiy9L8qpwJDtx5iWhtSioH33SXJ52WpaZW", | ||
* "type": 5, | ||
* "version": 2, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "assetId": "3toqCSpAHShatE75UFKxqymuWFr8nxuxD7UcLjdxVFLx", | ||
@@ -41,5 +45,5 @@ * "quantity": 10000, | ||
* "fee": 100000000, | ||
* "timestamp": 1549967848229, | ||
* "timestamp": 1550234087048, | ||
* "proofs": [ | ||
* "4PA41pxKJ6TqTDPi9uDT1MHf1vE2dHBaMRfj1wokzEsRWBUbtVfHttyCL5w93Ck6MZM2upbXgvDZ3LMymt6LB4eL" | ||
* "7WaArxgryXfq1zAGSPXyP1xr93DfbMMHWT7ordXbWn3qswQs1seZNvMt2SQKvXsjaBRQnrsKaY8nbmoNRuTNnFZ" | ||
* ] | ||
@@ -46,0 +50,0 @@ * } |
@@ -6,13 +6,17 @@ import { ISetScriptTransaction, ISetScriptParams, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[ISetScriptTransaction]] as a second argument. | ||
* Also you can use already formed [[ISetScriptTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { setScript } = require('waves-transactions') | ||
* const { setScript } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
* const params = { | ||
* script: 'AQa3b8tH', //true | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
@@ -28,11 +32,11 @@ * //fee: 100000, | ||
* { | ||
* "id": "H4JNEpaQgxnkNsAfBb6VgA2bbkDMpEsnxuPEu5zEg1Ja", | ||
* "id": "Fow5AeVSjRpyxtFYMBKpPYtopz3LcN3LaxjPpcW9rtK1", | ||
* "type": 13, | ||
* "version": 1, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "chainId": 87, | ||
* "fee": 1000000, | ||
* "timestamp": 1549967848263, | ||
* "timestamp": 1550234087080, | ||
* "proofs": [ | ||
* "2SuTygXTKTSUHP4cZWegHPm3gYpkNEw99ySsk16tCj5sS2Jo2rM7zvyhz9ZvJRJMUDedy396MAj2MGYpAxsU7Eey" | ||
* "YFr2kUNphfoKWR2iqZwCy9JQYPfwrZXLFbCBSXiUr8BhLoxBybHVa8pLRNEtekKJEDTKNcNpRDzrDZApQpfsfwk" | ||
* ], | ||
@@ -39,0 +43,0 @@ * "script": "base64:AQa3b8tH" |
@@ -6,10 +6,13 @@ import { ITransferTransaction, ITransferParams, WithId, WithSender } from '../transactions'; | ||
* | ||
* If no senderPublicKey is set, it will be derived from seed. | ||
* In case sender and signer are different, you need to pass senderPublicKey explicitly. | ||
* | ||
* You can use this function with multiple seeds. In this case it will sign transaction accordingly and will add one proof per seed. | ||
* Also you can use already signed [[ITransferTransaction]] as a second argument. | ||
* Also you can use already formed [[ITransferTransaction]] instead of params. | ||
* | ||
* ### Usage | ||
* ```js | ||
* const { transfer } = require('waves-transactions') | ||
* const { transfer } = require('@waves/waves-transactions') | ||
* | ||
* const seed = 'b716885e9ba64442b4f1263c8e2d8671e98b800c60ec4dc2a27c83e5f9002b18' | ||
* const seed = 'example seed phrase' | ||
* | ||
@@ -23,2 +26,3 @@ * //Transfering 1 WAVES | ||
* //attachment: undefined | ||
* //senderPublicKey: 'by default derived from seed', | ||
* //timestamp: Date.now(), | ||
@@ -33,6 +37,6 @@ * //fee: 100000, | ||
* { | ||
* "id": "EDwa8kur8VTwkjPEb5aSP4ohqzJryvMca6szBsdyDuhs", | ||
* "id": "7WvpJCqW8JW66e7Ne3UfFDoqiz8L6Ptfze4PtemKJZnf", | ||
* "type": 4, | ||
* "version": 2, | ||
* "senderPublicKey": "G62H1XE5rnaCgCCURV5pWwQHzWezZB7VkkVgqthdKgkj", | ||
* "senderPublicKey": "3SU7zKraQF8tQAF8Ho75MSVCBfirgaQviFXnseEw4PYg", | ||
* "recipient": "3P23fi1qfVw6RVDn4CH2a5nNouEtWNQ4THs", | ||
@@ -42,5 +46,5 @@ * "amount": 100000000, | ||
* "fee": 100000, | ||
* "timestamp": 1549967848238, | ||
* "timestamp": 1550234087056, | ||
* "proofs": [ | ||
* "397RRue1QCSqeAbaNA5Mssmx6zTzrHLXuPGtHuCNhDzg3wUyPPgmEyyCcmBc7ksrME7ZRxTSTbVkjtED5ZLLspcZ" | ||
* "4S4Pg98NzMht3Kb1RjbYdQqyEEKrcFJrayvJf6kEzq2KYggEErazDuM7jcKnQorh1CgdyVwUe4B9kM52TMzChFTc" | ||
* ] | ||
@@ -47,0 +51,0 @@ * } |
{ | ||
"name": "@waves/waves-transactions", | ||
"version": "3.0.26", | ||
"version": "3.1.0", | ||
"description": "Build and sign(multi-sign) transactions for Waves blockchain.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -39,10 +39,4 @@ # waves-transactions [](https://badge.fury.io/js/%40waves%2Fwaves-transactions) | ||
recipient: '3P6fVra21KmTfWHBdib45iYV6aFduh4WwC2', | ||
timestamp: 1536917842558, //Timestamp is optional but it was overrided, in case timestamp is not provided it will fallback to Date.now() | ||
//Every function from the list above has a set of required and optional params | ||
//senderPublicKey: 'Cq5itmx4wbYuogySAoUp58MimLLkQrFFLr1tpJy2BYp1', // By default it is derived from seed, | ||
// but if you don't want to sign transaction you have to provide it | ||
//fee: 100000, //Fee is always optional, in case fee is not provided, it will be calculated for you | ||
//additionalFee: 400000, //If fee is not set, this value will be added to the auto calculated value | ||
//feeAssetId: undefined | ||
//Timestamp is optional but it was overrided, in case timestamp is not provided it will fallback to Date.now(). You can set any oftional params yourself. go check full docs | ||
timestamp: 1536917842558 | ||
}, seed) | ||
@@ -71,2 +65,12 @@ ``` | ||
You can also create transaction, but not sign it: | ||
```javascript | ||
const unsignedTransferTx = transfer({ | ||
amount: 1, | ||
recipient: '3P6fVra21KmTfWHBdib45iYV6aFduh4WwC2', | ||
//senderPublicKey is required if you omit seed | ||
senderPublicKey: '6nR7CXVV7Zmt9ew11BsNzSvVmuyM5PF6VPbWHW9BHgPq' | ||
}) | ||
``` | ||
Now you are able to POST it to Waves API or store for future purpose or you can add another signature from other party: | ||
@@ -73,0 +77,0 @@ ```js |
import axios from 'axios' | ||
import { binary, json } from '@waves/marshall' | ||
import { verifySignature } from '@waves/waves-crypto' | ||
import { | ||
@@ -24,4 +26,4 @@ IAliasTransaction, | ||
import { setAssetScript } from './transactions/set-asset-script' | ||
import { binary, json } from '@waves/marshall' | ||
export interface WithTxType { | ||
@@ -66,2 +68,15 @@ type: TRANSACTION_TYPE | ||
/** | ||
* Verifies signature of transaction or order | ||
* @param obj | ||
* @param proofN - proof index. Takes first proof by default | ||
* @param publicKey - takes senderPublicKey by default | ||
*/ | ||
export function verify(obj: TTx | IOrder, proofN = 0, publicKey?: string): boolean { | ||
publicKey = publicKey || obj.senderPublicKey | ||
const bytes = serialize(obj) | ||
const signature = obj.version == null ? (obj as any).signature : obj.proofs[proofN] | ||
return verifySignature(publicKey, bytes, signature) | ||
} | ||
/** | ||
* Sends transaction to waves node | ||
@@ -68,0 +83,0 @@ * @param tx - transaction to send |
@@ -16,3 +16,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -19,0 +19,0 @@ }, |
@@ -19,3 +19,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -22,0 +22,0 @@ }, |
@@ -16,3 +16,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -19,0 +19,0 @@ }, |
@@ -26,3 +26,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -29,0 +29,0 @@ }, |
@@ -34,3 +34,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -37,0 +37,0 @@ }, |
@@ -19,3 +19,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -22,0 +22,0 @@ }, |
@@ -26,3 +26,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -29,0 +29,0 @@ }, |
@@ -22,3 +22,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -25,0 +25,0 @@ }, |
@@ -20,3 +20,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -23,0 +23,0 @@ }, |
@@ -20,3 +20,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -23,0 +23,0 @@ }, |
@@ -29,3 +29,3 @@ { | ||
"senderPublicKey": { | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You want only to create tx, not to sign it. Therefore no seed is provided.", | ||
"description": "If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases:\n1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures.\n2. You to create tx without proof. Therefore no seed is provided.", | ||
"type": "string" | ||
@@ -32,0 +32,0 @@ }, |
@@ -312,3 +312,3 @@ import { TypelessDataEntry } from './transactions/data' | ||
* 1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures. | ||
* 2. You want only to create tx, not to sign it. Therefore no seed is provided. | ||
* 2. You to create tx without proof. Therefore no seed is provided. | ||
*/ | ||
@@ -315,0 +315,0 @@ senderPublicKey?: string |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
100
4.17%492367
-0.99%153
-3.16%11704
-0.95%