@btc-vision/transaction 1.0.49 → 1.0.50

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.
@@ -1 +1 @@
1
- export declare const version = "1.0.49";
1
+ export declare const version = "1.0.50";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.0.49';
1
+ export const version = '1.0.50';
@@ -2,6 +2,5 @@
2
2
  import { Network } from 'bitcoinjs-lib';
3
3
  export declare class AddressGenerator {
4
4
  static generatePKSH(sha256Hash: Buffer, network: Network): string;
5
- private static ripemd160;
6
5
  private static toSegwitAddress;
7
6
  }
@@ -1,18 +1,15 @@
1
- import { createHash } from 'crypto';
2
1
  import { bech32 } from 'bech32';
3
2
  import { initEccLib } from 'bitcoinjs-lib';
4
3
  import * as ecc from '@bitcoinerlab/secp256k1';
4
+ import { ripemd160 } from 'bitcoinjs-lib/src/crypto';
5
5
  initEccLib(ecc);
6
6
  export class AddressGenerator {
7
7
  static generatePKSH(sha256Hash, network) {
8
8
  if (sha256Hash.length !== 32)
9
9
  throw new Error('Invalid hash length');
10
- const pkh = this.ripemd160(sha256Hash);
10
+ const pkh = ripemd160(sha256Hash);
11
11
  return this.toSegwitAddress(pkh, network);
12
12
  }
13
- static ripemd160(data) {
14
- return createHash('ripemd160').update(data).digest();
15
- }
16
13
  static toSegwitAddress(pkh, network) {
17
14
  const words = bech32.toWords(pkh);
18
15
  words.unshift(0x00);
@@ -15,7 +15,7 @@ function airdropToken(amount, to) {
15
15
  return Buffer.from(calldata.getBuffer());
16
16
  }
17
17
  const tokenAmount = expandToDecimals(1000, 8n);
18
- const receiver = 'bcrt1p2m2yz9hae5lkypuf8heh6udnt0tchmxhaftcfslqsr5vrwzh34yqgn6hs6';
18
+ const receiver = 'bcrt1ppqk36azyunxdpadza7gtf568elqxnhu3lwufg98daek3kz07390swyvzd2';
19
19
  const calldata = airdropToken(tokenAmount, receiver);
20
20
  console.log('airdrop ->', calldata.toString('hex'));
21
21
  await interact(MOTO_ADDRESS, calldata);
@@ -30,7 +30,7 @@ shuffleArray(utxos);
30
30
  if (!utxos) {
31
31
  throw new Error('No UTXOs found');
32
32
  }
33
- export async function interact(contract, calldata, mine = true, UTXOs = utxos) {
33
+ export async function interact(contract, calldata, mine = false, UTXOs = utxos) {
34
34
  let finalTx;
35
35
  for (let i = 0; i < UTXOs.length; i += 1) {
36
36
  let utxo = UTXOs[i];
@@ -44,7 +44,6 @@ export async function interact(contract, calldata, mine = true, UTXOs = utxos) {
44
44
  priorityFee: 10000n,
45
45
  calldata: calldata,
46
46
  };
47
- console.log(interactionParameters);
48
47
  try {
49
48
  finalTx = await factory.signInteraction(interactionParameters);
50
49
  let txid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "author": "BlobMaster41",
5
5
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
6
6
  "engines": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.0.49';
1
+ export const version = '1.0.50';
@@ -1,7 +1,7 @@
1
- import { createHash } from 'crypto';
2
1
  import { bech32 } from 'bech32';
3
2
  import { initEccLib, Network } from 'bitcoinjs-lib';
4
3
  import * as ecc from '@bitcoinerlab/secp256k1';
4
+ import { ripemd160 } from 'bitcoinjs-lib/src/crypto';
5
5
 
6
6
  initEccLib(ecc);
7
7
 
@@ -10,15 +10,10 @@ export class AddressGenerator {
10
10
  public static generatePKSH(sha256Hash: Buffer, network: Network): string {
11
11
  if (sha256Hash.length !== 32) throw new Error('Invalid hash length');
12
12
 
13
- const pkh = this.ripemd160(sha256Hash);
13
+ const pkh = ripemd160(sha256Hash);
14
14
  return this.toSegwitAddress(pkh, network);
15
15
  }
16
16
 
17
- // Compute the RIPEMD-160 hash of a buffer
18
- private static ripemd160(data: Buffer): Buffer {
19
- return createHash('ripemd160').update(data).digest();
20
- }
21
-
22
17
  // Convert a hash to a SegWit address
23
18
  private static toSegwitAddress(pkh: Buffer, network: Network): string {
24
19
  const words = bech32.toWords(pkh);