Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore #7

Merged
merged 6 commits into from
Aug 24, 2023
Merged

Chore #7

merged 6 commits into from
Aug 24, 2023

Conversation

limpbrains
Copy link
Collaborator

  • move source files to src/. This makes easier to publish the library, also sources may be published with compiled files as a reference
  • rewrite sp._sumPrivkeys to fix typescript errors
  • replace babel/jest with ts-jest. Less dependencies, type-check now included in test.
  • other minor changes

@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this sorcery

"include": ["index.ts", "noble_ecc.ts"]
"compilerOptions": {
"target": "ES2016",
"outDir": "./dist",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we commit dist to git?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't, but it will be published in npm package

bitcoin.initEccLib(ecc);
import { SilentPayment } from "../src";
import ecc from "../src/noble_ecc";
import jsonImput from "./data/sending_test_vectors.json";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imput
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this or eslint-ptsr

const ECPair = ECPairFactory(ecc);
const bitcoin = require("bitcoinjs-lib");
bitcoin.initEccLib(ecc);

type UTXO = {
txid: string;
vout: number;
WIF: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something to think about: if we change api from requiring WIF to requiring simply privkey, we can drop ecpair as a dependency

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, we can use ecpair it tests and docs, but remove it from dependencies.

let key = ECPair.fromWIF(utxo.WIF).privateKey;

if (key === undefined) {
throw new Error("No private key found for UTXO");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not found? maybe, invalid?
i think ECPair.fromWIF() will throw if you feed undefined or garbage to it. not sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this check, because according to ecpair typescript types ECPair.fromWIF() returns ECPairInterface with optinal privateKey. So I just added this check to make typescript happy, maybe it's redundant.

@Overtorment Overtorment merged commit 4643fa0 into BlueWallet:master Aug 24, 2023
1 check passed
@limpbrains limpbrains deleted the ts branch August 28, 2023 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants