@neuraiproject/neurai-sign-esp32 0.7.2 → 0.8.0

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.
package/README.md CHANGED
@@ -866,6 +866,10 @@ to any Neurai address type. Returns base64 string.
866
866
  Build an unsigned PSBT from an already-created raw unsigned transaction plus
867
867
  input metadata. This is the preferred path when the wallet already handles coin
868
868
  selection, fee calculation, asset outputs, and change outputs externally.
869
+ `inputs[i]` must describe input `i` (`txid:vout`); unlocking data in the raw
870
+ transaction is not carried. Any Neurai transaction version is accepted, and
871
+ `witnessScript` puts the script behind an AuthScript input (a covenant) in the
872
+ PSBT for signers that handle it (Neurai Connect); the device does not.
869
873
 
870
874
  ### `finalizePSBT(base64, network)`
871
875
 
@@ -873,13 +877,24 @@ Finalize a signed PSBT. Returns `{ txHex, txId }`.
873
877
 
874
878
  ### `finalizeSignedPSBT(originalPsbtBase64, signedPsbtBase64, network)`
875
879
 
876
- Merge a signed PSBT returned by the device with the original PSBT and finalize it.
877
- This helper also supports the minimal PSBT format returned by `uNeurai`, and
878
- includes fallback logic for legacy P2PKH finalization used by Neurai.
880
+ Merge a signed PSBT (from the device or another signer) with the original PSBT,
881
+ finalize the inputs it signed and extract the transaction; unsigned inputs are
882
+ left empty. A standard PSBT is combined: a field the two disagree on, or a
883
+ different transaction, is an error. Only an answer that is not a readable PSBT
884
+ is read as the minimal form `uNeurai` writes, and only if its transaction is
885
+ byte for byte the original one. A signature whose sighash byte differs from the
886
+ input's `sighashType` is rejected (it is no longer adjusted).
887
+
888
+ ### `assertDeviceCanSignPSBT(base64)`
889
+
890
+ Throws for what the NeuraiHW firmware cannot sign: a version-3 transaction, a
891
+ version-3 previous transaction, an input with a `witnessScript`.
892
+ `NeuraiESP32.signPsbt` calls it before sending anything to the device.
879
893
 
880
894
  ### `validatePSBT(base64, network)`
881
895
 
882
- Check if a PSBT base64 string is parseable. Returns boolean.
896
+ Check if a PSBT base64 string is readable under the Neurai PSBT profile
897
+ (previous transactions matching their outpoints). Returns boolean.
883
898
 
884
899
  [Check the TypeScript definitions](./dist/index.d.ts) for all the details.
885
900
 
@@ -943,6 +958,32 @@ ArduinoJson parser was checked on the host up to MAX_MONEY; this does not replac
943
958
  an on-device signing and display check of the firmware installed on your ESP32.
944
959
  No global bigint JSON serializer is required.
945
960
 
961
+ ## Upgrading to 0.8.0
962
+
963
+ The PSBT helpers no longer use bitcoinjs-lib's `Psbt`: they are built on the
964
+ PSBT module of `@neuraiproject/neurai-create-transaction` `^0.9.3` (BIP-174
965
+ version 0 whose transactions use the Neurai serialization). Same functions and
966
+ signatures; for the cases 0.7.2 supported (P2PKH and strict ECDSA v3 inputs,
967
+ transactions version 1/2) the PSBTs and transactions are byte for byte the
968
+ same.
969
+
970
+ - `buildPSBTFromRawTransaction` accepts version-3 transactions and the new
971
+ `IPSBTInputMetadata.witnessScript`, for Neurai Connect signers. It now checks
972
+ that each metadata entry describes its input (`txid:vout`).
973
+ - `NeuraiESP32.signPsbt` rejects, before the device is involved, what the
974
+ firmware cannot sign: version-3 transactions or previous transactions, and
975
+ inputs with a `witnessScript` (`assertDeviceCanSignPSBT`, exported).
976
+ - `finalizeSignedPSBT` no longer changes an input's `sighashType` to match the
977
+ returned signature: a mismatch is an error. uNeurai's `PSBT::sign` signs with
978
+ the input's `PSBT_IN_SIGHASH_TYPE` (`SIGHASH_ALL` when absent), so firmware
979
+ answers match the PSBT they were given.
980
+ - `finalizeSignedPSBT` no longer falls back to the minimal-PSBT reader when a
981
+ readable answer conflicts with the original or is for another transaction;
982
+ the minimal reader itself checks the transaction against the original.
983
+ - Error messages of invalid PSBTs come from neurai-create-transaction.
984
+ - `npm run test:package` accepts dependencies not yet on npm as tarballs:
985
+ `NEURAI_PACKAGE_CHECK_TARBALLS=/path/a.tgz,/path/b.tgz`.
986
+
946
987
  ## Upgrading to 0.7.2
947
988
 
948
989
  Previous transactions may be Neurai version-3 transactions (privacy pools and