Page MenuHomePhabricator

[ecash-lib] Add `pushBytesOp` to make a minimal bytes pushop
ClosedPublic

Authored by tobias_ruck on Apr 10 2024, 22:55.

Details

Summary

Script requires to use minimally encoded push ops. pushBytesOp creates a minimal Op for us that pushes the given bytes.

Depends on D15938.

Test Plan

npm run test && npm run build

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.

re-run CI

modules/ecash-lib/src/op.ts
99 ↗(On Diff #47011)

mb getMinPushBytesOp, pushBytesOpScript, or something more specific?

we will need similar-ish function(s) for different specific use cases like SLP

This revision now requires changes to proceed.Apr 11 2024, 03:55

fix pushBytesOp case where data starts with eg. 16 but isn't size 1

Tail of the build log:

Test does not depend on mock-chronik-client, skipping mock-chronik-client dependencies...
Test depends on ecash-lib-wasm. Building WebAssembly...
/work/modules/ecash-lib-wasm /work/abc-ci-builds/ecash-lib-tests
./build-wasm.sh: line 5: cargo: command not found
Failed opening './target/wasm32-unknown-unknown/release-wasm/ecash_lib_wasm.wasm'
./build-wasm.sh: line 19: wasm-bindgen: command not found
Build ecash-lib-tests failed with exit code 127
modules/ecash-lib/src/op.ts
99 ↗(On Diff #47011)

This function will be used a lot in covenants, so keeping it small and concise makes the most sense.
Also, it's kind of the default, and SLP really is the exception, so IMO the naming makes sense.

If the SLP deviation didn't exist I wouldn't even add this function and just have type Op = number | Uint8Array and always encode minimally, but this way we kinda keep the conciseness without the lack of explicitness.

This revision is now accepted and ready to land.Apr 11 2024, 22:44