cashscript 0.7.6 → 0.8.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -6
- package/dist/{main/Argument.d.ts → Argument.d.ts} +1 -1
- package/dist/{module/Argument.js → Argument.js} +1 -1
- package/dist/{module/Contract.d.ts → Contract.d.ts} +8 -6
- package/dist/{module/Contract.js → Contract.js} +15 -25
- package/dist/{main/Errors.d.ts → Errors.d.ts} +4 -1
- package/dist/{module/Errors.js → Errors.js} +7 -3
- package/dist/{main/SignatureTemplate.d.ts → SignatureTemplate.d.ts} +2 -3
- package/dist/{module/SignatureTemplate.js → SignatureTemplate.js} +4 -5
- package/dist/{module/Transaction.d.ts → Transaction.d.ts} +7 -5
- package/dist/Transaction.js +352 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -0
- package/dist/{main/index.d.ts → index.d.ts} +1 -1
- package/dist/{module/index.js → index.js} +2 -3
- package/dist/{module/interfaces.d.ts → interfaces.d.ts} +33 -6
- package/dist/{module/interfaces.js → interfaces.js} +0 -2
- package/dist/{module/network → network}/BitcoinRpcNetworkProvider.d.ts +2 -3
- package/dist/network/BitcoinRpcNetworkProvider.js +29 -0
- package/dist/{module/network → network}/ElectrumNetworkProvider.js +53 -72
- package/dist/network/FullStackNetworkProvider.js +33 -0
- package/dist/{main/network → network}/index.d.ts +0 -1
- package/dist/{module/network → network}/index.js +0 -1
- package/dist/{main/utils.d.ts → utils.d.ts} +10 -6
- package/dist/{module/utils.js → utils.js} +90 -46
- package/package.json +18 -16
- package/dist/main/Argument.js +0 -60
- package/dist/main/Contract.d.ts +0 -23
- package/dist/main/Contract.js +0 -87
- package/dist/main/Errors.js +0 -84
- package/dist/main/SignatureTemplate.js +0 -45
- package/dist/main/Transaction.d.ts +0 -39
- package/dist/main/Transaction.js +0 -258
- package/dist/main/constants.d.ts +0 -5
- package/dist/main/constants.js +0 -9
- package/dist/main/index.js +0 -50
- package/dist/main/interfaces.d.ts +0 -43
- package/dist/main/interfaces.js +0 -32
- package/dist/main/network/BitboxNetworkProvider.d.ts +0 -26
- package/dist/main/network/BitboxNetworkProvider.js +0 -40
- package/dist/main/network/BitcoinRpcNetworkProvider.d.ts +0 -41
- package/dist/main/network/BitcoinRpcNetworkProvider.js +0 -49
- package/dist/main/network/ElectrumNetworkProvider.js +0 -162
- package/dist/main/network/FullStackNetworkProvider.js +0 -55
- package/dist/main/network/NetworkProvider.js +0 -3
- package/dist/main/network/index.js +0 -15
- package/dist/main/utils.js +0 -205
- package/dist/module/Argument.d.ts +0 -3
- package/dist/module/Errors.d.ts +0 -66
- package/dist/module/SignatureTemplate.d.ts +0 -15
- package/dist/module/Transaction.js +0 -251
- package/dist/module/constants.d.ts +0 -5
- package/dist/module/constants.js +0 -6
- package/dist/module/index.d.ts +0 -10
- package/dist/module/network/BitboxNetworkProvider.d.ts +0 -26
- package/dist/module/network/BitboxNetworkProvider.js +0 -37
- package/dist/module/network/BitcoinRpcNetworkProvider.js +0 -46
- package/dist/module/network/ElectrumNetworkProvider.d.ts +0 -19
- package/dist/module/network/FullStackNetworkProvider.d.ts +0 -40
- package/dist/module/network/FullStackNetworkProvider.js +0 -52
- package/dist/module/network/NetworkProvider.d.ts +0 -31
- package/dist/module/network/index.d.ts +0 -5
- package/dist/module/utils.d.ts +0 -26
- /package/dist/{main/network → network}/ElectrumNetworkProvider.d.ts +0 -0
- /package/dist/{main/network → network}/FullStackNetworkProvider.d.ts +0 -0
- /package/dist/{main/network → network}/NetworkProvider.d.ts +0 -0
- /package/dist/{module/network → network}/NetworkProvider.js +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
const RpcClientRetry = require('bitcoin-rpc-promise-retry');
|
|
11
|
-
export default class BitcoinRpcNetworkProvider {
|
|
12
|
-
constructor(network, url, opts) {
|
|
13
|
-
this.network = network;
|
|
14
|
-
this.rpcClient = new RpcClientRetry(url, opts);
|
|
15
|
-
}
|
|
16
|
-
getUtxos(address) {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const result = yield this.rpcClient.listUnspent(0, 9999999, [address]);
|
|
19
|
-
const utxos = result.map((utxo) => ({
|
|
20
|
-
txid: utxo.txid,
|
|
21
|
-
vout: utxo.vout,
|
|
22
|
-
satoshis: utxo.amount * 1e8,
|
|
23
|
-
}));
|
|
24
|
-
return utxos;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
getBlockHeight() {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
return this.rpcClient.getBlockCount();
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
getRawTransaction(txid) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
return this.rpcClient.getRawTransaction(txid);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
sendRawTransaction(txHex) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
return this.rpcClient.sendRawTransaction(txHex);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
getClient() {
|
|
43
|
-
return this.rpcClient;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=BitcoinRpcNetworkProvider.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ElectrumCluster } from 'electrum-cash';
|
|
2
|
-
import { Utxo, Network } from '../interfaces.js';
|
|
3
|
-
import NetworkProvider from './NetworkProvider.js';
|
|
4
|
-
export default class ElectrumNetworkProvider implements NetworkProvider {
|
|
5
|
-
network: Network;
|
|
6
|
-
private manualConnectionManagement?;
|
|
7
|
-
private electrum;
|
|
8
|
-
private concurrentRequests;
|
|
9
|
-
constructor(network?: Network, electrum?: ElectrumCluster, manualConnectionManagement?: boolean | undefined);
|
|
10
|
-
getUtxos(address: string): Promise<Utxo[]>;
|
|
11
|
-
getBlockHeight(): Promise<number>;
|
|
12
|
-
getRawTransaction(txid: string): Promise<string>;
|
|
13
|
-
sendRawTransaction(txHex: string): Promise<string>;
|
|
14
|
-
connectCluster(): Promise<void[]>;
|
|
15
|
-
disconnectCluster(): Promise<boolean[]>;
|
|
16
|
-
private performRequest;
|
|
17
|
-
private shouldConnect;
|
|
18
|
-
private shouldDisconnect;
|
|
19
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Utxo, Network } from '../interfaces.js';
|
|
2
|
-
import NetworkProvider from './NetworkProvider.js';
|
|
3
|
-
export default class FullStackNetworkProvider implements NetworkProvider {
|
|
4
|
-
network: Network;
|
|
5
|
-
private bchjs;
|
|
6
|
-
/**
|
|
7
|
-
* @example
|
|
8
|
-
* const BCHJS = require("@psf/bch-js")
|
|
9
|
-
* let bchjs = new BCHJS({
|
|
10
|
-
* restURL: 'https://api.fullstack.cash/v3/',
|
|
11
|
-
* apiToken: 'eyJhbGciO...' // Your JWT token here.
|
|
12
|
-
* })
|
|
13
|
-
*/
|
|
14
|
-
constructor(network: Network, bchjs: BCHJS);
|
|
15
|
-
getUtxos(address: string): Promise<Utxo[]>;
|
|
16
|
-
getBlockHeight(): Promise<number>;
|
|
17
|
-
getRawTransaction(txid: string): Promise<string>;
|
|
18
|
-
sendRawTransaction(txHex: string): Promise<string>;
|
|
19
|
-
}
|
|
20
|
-
interface ElectrumUtxo {
|
|
21
|
-
tx_pos: number;
|
|
22
|
-
value: number;
|
|
23
|
-
tx_hash: string;
|
|
24
|
-
height: number;
|
|
25
|
-
}
|
|
26
|
-
interface BCHJS {
|
|
27
|
-
Electrumx: {
|
|
28
|
-
utxo(address: string): Promise<{
|
|
29
|
-
utxos: ElectrumUtxo[];
|
|
30
|
-
}>;
|
|
31
|
-
};
|
|
32
|
-
Blockchain: {
|
|
33
|
-
getBlockCount(): Promise<number>;
|
|
34
|
-
};
|
|
35
|
-
RawTransactions: {
|
|
36
|
-
getRawTransaction(txid: string): Promise<string>;
|
|
37
|
-
sendRawTransaction(txHex: string): Promise<string>;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export default class FullStackNetworkProvider {
|
|
11
|
-
/**
|
|
12
|
-
* @example
|
|
13
|
-
* const BCHJS = require("@psf/bch-js")
|
|
14
|
-
* let bchjs = new BCHJS({
|
|
15
|
-
* restURL: 'https://api.fullstack.cash/v3/',
|
|
16
|
-
* apiToken: 'eyJhbGciO...' // Your JWT token here.
|
|
17
|
-
* })
|
|
18
|
-
*/
|
|
19
|
-
constructor(network, bchjs) {
|
|
20
|
-
this.network = network;
|
|
21
|
-
this.bchjs = bchjs;
|
|
22
|
-
}
|
|
23
|
-
getUtxos(address) {
|
|
24
|
-
var _a;
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const result = yield this.bchjs.Electrumx.utxo(address);
|
|
27
|
-
const utxos = ((_a = result.utxos) !== null && _a !== void 0 ? _a : []).map((utxo) => ({
|
|
28
|
-
txid: utxo.tx_hash,
|
|
29
|
-
vout: utxo.tx_pos,
|
|
30
|
-
satoshis: utxo.value,
|
|
31
|
-
height: utxo.height,
|
|
32
|
-
}));
|
|
33
|
-
return utxos;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
getBlockHeight() {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return this.bchjs.Blockchain.getBlockCount();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
getRawTransaction(txid) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return this.bchjs.RawTransactions.getRawTransaction(txid);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
sendRawTransaction(txHex) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return this.bchjs.RawTransactions.sendRawTransaction(txHex);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=FullStackNetworkProvider.js.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Utxo, Network } from '../interfaces.js';
|
|
2
|
-
export default interface NetworkProvider {
|
|
3
|
-
/**
|
|
4
|
-
* Variable indicating the network that this provider connects to.
|
|
5
|
-
*/
|
|
6
|
-
network: Network;
|
|
7
|
-
/**
|
|
8
|
-
* Retrieve all UTXOs (confirmed and unconfirmed) for a given address.
|
|
9
|
-
* @param address The CashAddress for which we wish to retrieve UTXOs.
|
|
10
|
-
* @returns List of UTXOs spendable by the provided address.
|
|
11
|
-
*/
|
|
12
|
-
getUtxos(address: string): Promise<Utxo[]>;
|
|
13
|
-
/**
|
|
14
|
-
* @returns The current block height.
|
|
15
|
-
*/
|
|
16
|
-
getBlockHeight(): Promise<number>;
|
|
17
|
-
/**
|
|
18
|
-
* Retrieve the Hex transaction details for a given transaction ID.
|
|
19
|
-
* @param txid Hex transaction ID.
|
|
20
|
-
* @throws {Error} If the transaction does not exist
|
|
21
|
-
* @returns The full hex transaction for the provided transaction ID.
|
|
22
|
-
*/
|
|
23
|
-
getRawTransaction(txid: string): Promise<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Broadcast a raw hex transaction to the Bitcoin Cash network.
|
|
26
|
-
* @param txHex The raw transaction hex to be broadcast.
|
|
27
|
-
* @throws {Error} If the transaction was not accepted by the network.
|
|
28
|
-
* @returns The transaction ID corresponding to the broadcast transaction.
|
|
29
|
-
*/
|
|
30
|
-
sendRawTransaction(txHex: string): Promise<string>;
|
|
31
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { default as NetworkProvider } from './NetworkProvider.js';
|
|
2
|
-
export { default as BitboxNetworkProvider } from './BitboxNetworkProvider.js';
|
|
3
|
-
export { default as BitcoinRpcNetworkProvider } from './BitcoinRpcNetworkProvider.js';
|
|
4
|
-
export { default as ElectrumNetworkProvider } from './ElectrumNetworkProvider.js';
|
|
5
|
-
export { default as FullStackNetworkProvider } from './FullStackNetworkProvider.js';
|
package/dist/module/utils.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Transaction } from '@bitauth/libauth';
|
|
2
|
-
import { Script } from '@cashscript/utils';
|
|
3
|
-
import { Utxo, Output, Recipient } from './interfaces.js';
|
|
4
|
-
import { FailedTransactionError } from './Errors.js';
|
|
5
|
-
export declare function validateRecipient(recipient: Recipient): void;
|
|
6
|
-
export declare function getInputSize(inputScript: Uint8Array): number;
|
|
7
|
-
export declare function getPreimageSize(script: Uint8Array): number;
|
|
8
|
-
export declare function getTxSizeWithoutInputs(outputs: Output[]): number;
|
|
9
|
-
export declare function createInputScript(redeemScript: Script, encodedArgs: Uint8Array[], selector?: number, preimage?: Uint8Array): Uint8Array;
|
|
10
|
-
export declare function createOpReturnOutput(opReturnData: string[]): Output;
|
|
11
|
-
export declare function createSighashPreimage(transaction: Transaction, input: {
|
|
12
|
-
satoshis: number;
|
|
13
|
-
}, inputIndex: number, coveredBytecode: Uint8Array, hashtype: number): Uint8Array;
|
|
14
|
-
export declare function buildError(reason: string, meepStr: string): FailedTransactionError;
|
|
15
|
-
export declare function meep(tx: any, utxos: Utxo[], script: Script): string;
|
|
16
|
-
export declare function scriptToAddress(script: Script, network: string): string;
|
|
17
|
-
export declare function scriptToLockingBytecode(script: Script): Uint8Array;
|
|
18
|
-
/**
|
|
19
|
-
* Helper function to convert an address to a locking script
|
|
20
|
-
*
|
|
21
|
-
* @param address Address to convert to locking script
|
|
22
|
-
*
|
|
23
|
-
* @returns a locking script corresponding to the passed address
|
|
24
|
-
*/
|
|
25
|
-
export declare function addressToLockScript(address: string): Uint8Array;
|
|
26
|
-
export declare function getNetworkPrefix(network: string): 'bitcoincash' | 'bchtest' | 'bchreg';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|