-
Notifications
You must be signed in to change notification settings - Fork 7
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
Chore #7
Conversation
limpbrains
commented
Aug 20, 2023
- 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} */ |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.