Skip to content

Add optional OP_RETURN field to Send screen#1927

Open
EricGrill wants to merge 1 commit into
sparrowwallet:masterfrom
EricGrill:feature/op-return-field
Open

Add optional OP_RETURN field to Send screen#1927
EricGrill wants to merge 1 commit into
sparrowwallet:masterfrom
EricGrill:feature/op-return-field

Conversation

@EricGrill

Copy link
Copy Markdown

Summary

  • Adds an optional OP_RETURN field to each payment tab on the Send screen
  • Allows users to embed arbitrary data (up to 80 bytes) in their Bitcoin transactions
  • The OP_RETURN output has 0 value as required by the Bitcoin protocol

Implementation Details

  • New OP_RETURN text field added to the payment form (payment.fxml)
  • Real-time byte count display with validation status indicator
  • Validation for the 80-byte maximum limit with visual feedback
  • OP_RETURN data is encoded as UTF-8
  • Multiple payments can each have their own OP_RETURN data
  • Existing OP_RETURN functionality (BIP47 notifications) is preserved and works alongside user-entered data

Technical Changes

  • PaymentController.java: Added FXML field declarations, getOpReturnData(), isValidOpReturn(), updateOpReturnStatus(), and clearOpReturn() methods
  • SendController.java: Added getOpReturnsFromPaymentTabs() and areAllOpReturnsValid() methods, modified updateTransaction() to combine user-entered OP_RETURN data with existing opReturnsList
  • payment.fxml: Added new OP_RETURN field with tooltip and status indicator

Screenshots

The OP_RETURN field appears below the Amount field in each payment tab, with a status indicator showing the byte count and validation state.

Test plan

  • Verify the OP_RETURN field appears on the Send screen
  • Test entering data and observing the byte count
  • Test exceeding 80 bytes and verify validation error
  • Create a transaction with OP_RETURN data and verify it's included in the transaction
  • Test clearing the form and verify OP_RETURN field is cleared
  • Test multiple payment tabs with different OP_RETURN data
  • Verify BIP47 notification transactions still work correctly

Closes #97

🤖 Generated with Claude Code

Adds an optional OP_RETURN field to each payment tab on the Send screen,
allowing users to embed arbitrary data (up to 80 bytes) in their
transactions. The OP_RETURN output has 0 value as required by the
Bitcoin protocol.

Features:
- New OP_RETURN text field on the payment form
- Real-time byte count display with validation status
- Validation for the 80-byte maximum limit
- OP_RETURN data is encoded as UTF-8
- Multiple payments can each have their own OP_RETURN data
- Existing OP_RETURN functionality (BIP47 notifications) preserved

Closes sparrowwallet#97

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tigernero79

Copy link
Copy Markdown

Can I know in which version this very useful feature will be implemented, at least for me?

Or how can I use it today with Sparrow Wallet 2.4.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New field to add OP_RETURN output

2 participants