@btc-vision/transaction 1.0.94 → 1.0.95

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.
Files changed (32) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/generators/builders/MultiSignGenerator.d.ts +1 -0
  3. package/browser/index.js +1 -1
  4. package/browser/opnet.d.ts +0 -1
  5. package/browser/transaction/browser/Web3Provider.d.ts +2 -2
  6. package/browser/transaction/builders/DeploymentTransaction.d.ts +1 -0
  7. package/browser/transaction/processor/PsbtTransaction.d.ts +0 -1
  8. package/browser/utils/BitcoinUtils.d.ts +1 -1
  9. package/build/_version.d.ts +1 -1
  10. package/build/_version.js +1 -1
  11. package/build/generators/builders/MultisignGenerator.d.ts +1 -0
  12. package/build/generators/builders/MultisignGenerator.js +4 -2
  13. package/build/opnet.d.ts +0 -1
  14. package/build/opnet.js +0 -1
  15. package/build/transaction/TransactionFactory.js +7 -2
  16. package/build/transaction/browser/Web3Provider.d.ts +2 -2
  17. package/build/transaction/builders/DeploymentTransaction.d.ts +1 -0
  18. package/build/transaction/builders/DeploymentTransaction.js +3 -0
  19. package/build/transaction/processor/PsbtTransaction.d.ts +0 -1
  20. package/build/transaction/processor/PsbtTransaction.js +0 -14
  21. package/build/utils/BitcoinUtils.d.ts +1 -1
  22. package/build/utils/BitcoinUtils.js +2 -2
  23. package/package.json +4 -5
  24. package/src/_version.ts +1 -1
  25. package/src/generators/builders/MultiSignGenerator.ts +9 -2
  26. package/src/opnet.ts +0 -3
  27. package/src/transaction/TransactionFactory.ts +559 -544
  28. package/src/transaction/browser/Web3Provider.ts +2 -2
  29. package/src/transaction/builders/DeploymentTransaction.ts +3 -0
  30. package/src/transaction/processor/PsbtTransaction.ts +0 -19
  31. package/src/utils/BitcoinUtils.ts +2 -2
  32. package/src/network/NetworkInformation.ts +0 -7
@@ -9,7 +9,7 @@ import { DeploymentResult, UnwrapResult, WrapResult } from '../TransactionFactor
9
9
 
10
10
  export type InteractionParametersWithoutSigner = Omit<IInteractionParameters, 'signer'>;
11
11
  export type IWrapParametersWithoutSigner = Omit<IWrapParameters, 'signer'>;
12
- export type IUnwrapParametersSigner = Omit<IUnwrapParameters, 'signer'>;
12
+ export type IUnwrapParametersWithoutSigner = Omit<IUnwrapParameters, 'signer'>;
13
13
  export type IDeploymentParametersWithoutSigner = Omit<IDeploymentParameters, 'signer' | 'network'>;
14
14
 
15
15
  export interface BroadcastTransactionOptions {
@@ -57,5 +57,5 @@ export interface Web3Provider {
57
57
 
58
58
  wrap(wrapParameters: IWrapParametersWithoutSigner): Promise<WrapResult>;
59
59
 
60
- unwrap(unwrapParameters: IUnwrapParametersSigner): Promise<UnwrapResult>;
60
+ unwrap(unwrapParameters: IUnwrapParametersWithoutSigner): Promise<UnwrapResult>;
61
61
  }
@@ -15,6 +15,7 @@ import { Address } from '@btc-vision/bsi-binary';
15
15
 
16
16
  export class DeploymentTransaction extends TransactionBuilder<TransactionType.DEPLOYMENT> {
17
17
  public type: TransactionType.DEPLOYMENT = TransactionType.DEPLOYMENT;
18
+ public static readonly MAXIMUM_CONTRACT_SIZE = 128*1024;
18
19
 
19
20
  /**
20
21
  * The contract address
@@ -82,6 +83,8 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
82
83
  this.bytecode = Compressor.compress(parameters.bytecode);
83
84
  if (!this.bytecode) throw new Error('Bytecode is required');
84
85
 
86
+ if (this.bytecode.length > DeploymentTransaction.MAXIMUM_CONTRACT_SIZE) throw new Error('Contract size overflow.');
87
+
85
88
  this.randomBytes = parameters.randomBytes || BitcoinUtils.rndBytes();
86
89
 
87
90
  this.contractSeed = this.getContractSeed();
@@ -133,25 +133,6 @@ export class PsbtTransaction extends TweakedTransaction {
133
133
  this.transaction.addOutput(output);
134
134
  }
135
135
 
136
- /**
137
- * Attempt to sign all inputs
138
- */
139
- public async attemptSignAllInputs(): Promise<boolean> {
140
- let signed = false;
141
- for (let i = 0; i < this.transaction.data.inputs.length; i++) {
142
- const input = this.transaction.data.inputs[i];
143
-
144
- try {
145
- await this.signInput(this.transaction, input, i, this.signer);
146
- signed = true;
147
- } catch (e) {
148
- console.log(`can not sign. input ${i}`, e);
149
- }
150
- }
151
-
152
- return signed;
153
- }
154
-
155
136
  /**
156
137
  * Attempt to finalize all inputs
157
138
  * @returns {boolean} True if all inputs were finalized
@@ -20,12 +20,12 @@ export class BitcoinUtils {
20
20
  * @returns {Buffer} The random bytes
21
21
  */
22
22
  public static rndBytes(): Buffer {
23
- const buf = BitcoinUtils.getRandomValues(64);
23
+ const buf = BitcoinUtils.getUnsafeRandomValues(64);
24
24
 
25
25
  return Buffer.from(buf);
26
26
  }
27
27
 
28
- public static getRandomValues(length: number): Buffer {
28
+ public static getUnsafeRandomValues(length: number): Buffer {
29
29
  if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
30
30
  const array = new Uint8Array(length);
31
31
  window.crypto.getRandomValues(array);
@@ -1,7 +0,0 @@
1
- import { IWallet } from '../keypair/interfaces/IWallet.js';
2
- import { BlockchainConfig } from '@btc-vision/bsi-common';
3
-
4
- export interface NetworkInformation {
5
- readonly wallet: IWallet;
6
- readonly config: BlockchainConfig;
7
- }