overwrite btc-signer Transaction#182
Conversation
WalkthroughAdds a local Transaction wrapper (src/utils/transaction.ts), switches project imports to it, and removes per-call allowUnknown*, allowUnknownInputs/Outputs flags across transaction construction/parsing. Types that referenced the external Transaction now reference the local wrapper. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant Tx as utils/transaction.Transaction
participant Btc as @scure/btc-signer.Transaction
Note over Tx,Btc: Creation/parsing now goes through local wrapper
Caller->>Tx: new Transaction(opts?) / fromPSBT(psbt, opts?) / fromRaw(raw, opts?)
activate Tx
Tx->>Tx: Merge opts with ARK_TX_OPTS (default unknown* = true)
Tx->>Btc: Delegate construct/parse with merged opts
activate Btc
Btc-->>Tx: Base Transaction instance
deactivate Btc
Tx-->>Caller: Wrapped Transaction instance
deactivate Tx
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/forfeit.ts(1 hunks)src/identity/index.ts(1 hunks)src/identity/singleKey.ts(1 hunks)src/index.ts(1 hunks)src/intent/index.ts(1 hunks)src/utils/arkTransaction.ts(2 hunks)src/utils/transaction.ts(1 hunks)src/wallet/onchain.ts(3 hunks)src/wallet/unroll.ts(4 hunks)test/e2e/vhtlc.test.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/wallet/unroll.ts (1)
src/utils/transaction.ts (1)
Transaction(9-27)
src/utils/transaction.ts (1)
src/index.ts (1)
Transaction(203-203)
test/e2e/vhtlc.test.ts (2)
src/index.ts (1)
Transaction(203-203)src/utils/transaction.ts (1)
Transaction(9-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (19)
src/identity/singleKey.ts (1)
6-6: LGTM! Import paths updated correctly.The import changes align with the project-wide adoption of the local Transaction wrapper while maintaining all existing functionality.
Also applies to: 9-9
src/utils/transaction.ts (2)
29-31: User options can override Ark defaults.The
withArkOptsfunction applies user options after Ark options ({ ...Transaction.ARK_TX_OPTS, ...opts }), allowing users to override the Ark defaults. While this provides flexibility, it means users could pass{ allowUnknown: false }and disable the Ark-specific behavior, potentially defeating the purpose of this wrapper.Consider whether this is intentional. If Ark options should always be enforced, reverse the merge order to
{ ...opts, ...Transaction.ARK_TX_OPTS }.
20-22: Confirm fromPSBT’s polymorphic return typeVerify that
@scure/btc-signer’sTransaction.fromPSBTis declared to returnthis(i.e. the subclass) rather than always the base type; if it doesn’t, you’ll need to cast or override to preserve subclass behavior.src/identity/index.ts (1)
1-1: LGTM! Import path updated correctly.The import change aligns with the project-wide adoption of the local Transaction wrapper.
src/index.ts (1)
1-1: LGTM! Import path updated correctly.The import change aligns with the local Transaction wrapper implementation and maintains the same public API surface.
src/forfeit.ts (1)
1-1: LGTM! Correctly uses the new Transaction wrapper.The removal of explicit
allowUnknown*options is correct since they're now provided by default through theARK_TX_OPTSin the local Transaction wrapper. The function logic remains unchanged.Also applies to: 10-13
src/wallet/unroll.ts (3)
2-2: LGTM! Import paths updated correctly.The import changes align with the project-wide adoption of the local Transaction wrapper.
Also applies to: 15-15
170-170: LGTM! Correctly uses Transaction.fromPSBT with default options.The removal of explicit options is correct since
allowUnknown: trueis now provided by default through the wrapper'sARK_TX_OPTS.
295-295: LGTM! Correctly uses Transaction constructor with default options.The removal of
allowUnknownInputs: trueis correct since it's now provided by default through the wrapper'sARK_TX_OPTS. Theversion: 2option is properly preserved.src/wallet/onchain.ts (2)
13-13: LGTM! Import path updated correctly.The import change aligns with the project-wide adoption of the local Transaction wrapper.
162-165: LGTM! Correctly uses Transaction constructor with appropriate options.The removal of
allowUnknownInputs: trueis correct since it's now provided by default through the wrapper'sARK_TX_OPTS. TheallowLegacyWitnessUtxo: trueoption is properly preserved as it's not part of the Ark defaults and is specific to this use case.test/e2e/vhtlc.test.ts (3)
17-17: LGTM! Import path updated correctly.The import change aligns with the project-wide adoption of the local Transaction wrapper, now imported from the main SDK export.
141-141: LGTM! Correctly uses Transaction.fromPSBT with default options.The removal of explicit
{ allowUnknown: true }is correct since this option is now provided by default through the wrapper'sARK_TX_OPTS.
234-234: LGTM! Correctly uses Transaction constructor with default options.The removal of
{ allowUnknownInputs: true }is correct since this option is now provided by default through the wrapper'sARK_TX_OPTS.src/intent/index.ts (3)
116-140: LGTM! Constructor simplified by relying on wrapper defaults.The
craftToSpendTxfunction now uses the local Transaction wrapper without explicitallowUnknown*options. This is consistent with the PR's goal to set these options as defaults in the wrapper.
143-199: LGTM! Constructor simplified by relying on wrapper defaults.The
craftToSignTxfunction now uses the local Transaction wrapper without explicitallowUnknown*options, consistent with the refactor goal.
1-5: Transaction wrapper correctly defaults allowUnknown optionsARK_TX_OPTS sets
allowUnknown,allowUnknownInputs, andallowUnknownOutputstotrueby default, so no further changes are needed.src/utils/arkTransaction.ts (2)
1-22: LGTM! Import changed to use local Transaction wrapper.The Transaction import has been moved from the external
@scure/btc-signerto the local./transactionwrapper. This change is consistent with the refactor insrc/intent/index.tsand aligns with the PR objective to standardize Transaction options.Note: Verification of the wrapper implementation is requested in the review comment for
src/intent/index.ts.
69-120: LGTM! Constructor simplified in buildVirtualTx.The
buildVirtualTxfunction now creates transactions using the local wrapper without explicitallowUnknown*options. This change propagates through the checkpoint transaction creation flow (viabuildCheckpointTxon line 139), ensuring consistent behavior across all Ark transactions.
overwrite the default options of btc-signer
Transaction.thus, this:
is equivalent to:
@bordalix @tiero please review
Summary by CodeRabbit
Refactor
Behavior Changes
Tests