Skip to content

Conversation

@SatoshiRoppongi
Copy link
Contributor

#4251

Implemented Features

  1. Payment Enum Addition:
    - Payment::Amount(Amount) - Bitcoin amount payment (existing functionality)
    - Payment::InscriptionId(InscriptionId) - Inscription ID payment (new functionality)
  2. Command Interface Changes:
    - Changed --amount parameter to --for
    - --for accepts either a Bitcoin amount or an inscription ID
  3. Create Functionality (src/subcommand/wallet/offer/create.rs):
    - Bitcoin Payment: Maintains existing logic for Bitcoin-based offers
    - Inscription Payment: Validates payment inscription exists in wallet and creates transaction with two inputs (target inscription + payment inscription)
  4. Accept Functionality (src/subcommand/wallet/offer/accept.rs):
    - Bitcoin Payment: Validates using balance change verification
    - Inscription Payment: Verifies that the specified inscription is present in the PSBT inputs

Command Examples

Bitcoin payment (existing functionality)

ord wallet offer create --inscription --for 1btc --fee-rate 1
ord wallet offer accept --inscription --for 1btc --psbt

Inscription-to-inscription swap (new functionality)

ord wallet offer create --inscription --for --fee-rate 1
ord wallet offer accept --inscription --for --psbt

Key Technical Details

  • Backward Compatibility: Maintains full compatibility with existing Bitcoin-based offers
  • Type Safety: Uses Rust's type system with a Payment enum to handle both payment types safely
  • Validation: Ensures payment inscriptions exist in wallet before creating offers
  • Transaction Structure: Creates proper Bitcoin transactions with multiple inputs for inscription swaps

Testing & Quality Assurance

  • Updated all existing tests to use the new --for parameter
  • Added comprehensive test for inscription-to-inscription swap functionality
  • All tests pass successfully, confirming no regression in existing functionality
  • Code passes formatting (just fmt) and linting (just clippy) checks

The implementation enables users to trade inscriptions directly with each other, expanding the utility of the ord wallet beyond Bitcoin-only transactions as originally requested in the GitHub
issue.

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.

1 participant