[ecash-lib] Basic primitives for building txs
Summary:
Add basic primitives for building Bitcoin txs:
- Tx, TxInput, TxOutput, OutPoint, the basic primitives comprising a tx.
- Script, currently just a wrapper around Uint8Array of the bytecode, but in the future gives a rich builder for Scripts.
- SignData: Attached to a TxInput (ignored during serialization), used when signing the input using BIP143.
Unlike the previous draft, this version uses a Writer interface to unify object size calculation and object serialization, significantly simplifying the implementation.
Also, the writer interface abstracts over the messiness of Uint8Array and DataView handling, especially keeping track of the current write/read offset within the data.
Test Plan:
npm install
Unittests
npm run test
Build
npm run build
React app
It's important this works in a React app with typescript, therefore, somewhere in a temp folder:
- npx create-react-app my-ecash-app --template typescript
- cd my-ecash-app
- npm install --save /my/path/to/bitcoin-abc/modules/ecash-lib
- Add to App.tsx: import * as ecash from 'ecash-lib'; console.log(ecash);
- npm start
- In the browser, it should now log a "Module" with "Bytes", "Script", "Tx", ...
Deno
Having deno too work would be great:
- mydeno.ts: import * as ecash '/my/path/to/bitcoin-abc/modules/ecash-lib/dist/index.js'; console.log(ecash);
- deno run mydeno.ts
Reviewers: bytesofman, #bitcoin_abc
Reviewed By: bytesofman, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D15928