Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Dogecoin #130

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Implement Dogecoin #130

wants to merge 1 commit into from

Conversation

nomo-app
Copy link
Owner

@nomo-app nomo-app commented Jan 8, 2025

Summary by CodeRabbit

  • New Features

    • Added full support for Dogecoin (DOGE) cryptocurrency
    • Introduced Dogecoin network type and address prefixes
    • Expanded transaction handling for Dogecoin
  • Tests

    • Added new test cases for Dogecoin endpoint and transaction fetching
    • Implemented input simulation support for Dogecoin transactions
  • Documentation

    • Defined Dogecoin-specific network parameters and constants

Copy link

coderabbitai bot commented Jan 8, 2025

Walkthrough

This pull request introduces comprehensive support for the Dogecoin cryptocurrency across multiple components of the codebase. The changes span network type definitions, address prefix handling, transaction building utilities, constants, and predefined assets. A new Dogecoin network type is added with specific configurations, including address prefixes, BIP standards, and network-specific parameters. The modifications enable the system to recognize, process, and interact with Dogecoin transactions and addresses, expanding the existing cryptocurrency support infrastructure.

Changes

File Change Summary
lib/src/crypto/network_type.dart Added Dogecoin network type constants and DOGECOIN_NETWORK class
lib/src/crypto/utxo/entities/payments/p2h.dart Extended address prefix support to include Dogecoin prefixes
lib/src/crypto/utxo/utils/send.dart Added support for DOGECOIN_NETWORK in input and output building functions
lib/src/domain/constants.dart Introduced Dogecoin-specific address prefixes and network BIP constants
lib/src/domain/predefined_assets.dart Added dogeCoin constant with Dogecoin metadata
test/ci/fetching/assets/doge_fetch_test.dart New test for Dogecoin transaction fetching
test/ci/fetching/endpoint_test.dart Added endpoint health test for Dogecoin
test/no_ci/input_simulation_test.dart Extended transaction simulation to support Dogecoin network

Sequence Diagram

sequenceDiagram
    participant Client
    participant NetworkType
    participant TransactionBuilder
    participant AddressHandler

    Client->>NetworkType: Select DOGECOIN_NETWORK
    NetworkType-->>Client: Network Configuration
    Client->>TransactionBuilder: Build Transaction
    TransactionBuilder->>AddressHandler: Validate Address Prefixes
    AddressHandler-->>TransactionBuilder: Address Validation Result
    TransactionBuilder-->>Client: Transaction Ready
Loading

Possibly related PRs

Suggested reviewers

  • ThomasFercher

Poem

🐶 Dogecoin dances, bits in flight,
A new network joins our crypto might!
From prefix to transaction's gleam,
Such wow, such code, such blockchain dream! 🚀
Much support, very implementation! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
test/ci/fetching/assets/doge_fetch_test.dart (2)

8-8: Test name could be more descriptive

The test name "No Structure Transaction with Xpub reject wallet" doesn't clearly indicate that this is a Dogecoin-specific test.

Consider renaming to "Dogecoin - Fetch transactions for wallet with no structure".


9-9: Remove or document the hardcoded address

The commented address D65DuQST2rnXaSeyEZQrerjSFCQjd8ZQ5T appears to be a test address but its purpose is unclear.

Either remove it if unused or document its purpose and whether it's a testnet/mainnet address.

test/ci/fetching/endpoint_test.dart (1)

23-35: Align test configuration with other cryptocurrencies

The test uses different parameters compared to other cryptocurrency tests:

  • Uses min: 1 while Zeniq uses min: 3
  • Placement between Zeniq and Bitcoin tests seems arbitrary

Consider:

  1. Increasing minimum endpoints for better reliability
  2. Moving the test to maintain alphabetical order with other cryptocurrency tests
-      min: 1,
+      min: 3,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 84ab46f and b1d1c58.

📒 Files selected for processing (8)
  • lib/src/crypto/network_type.dart (2 hunks)
  • lib/src/crypto/utxo/entities/payments/p2h.dart (1 hunks)
  • lib/src/crypto/utxo/utils/send.dart (2 hunks)
  • lib/src/domain/constants.dart (2 hunks)
  • lib/src/domain/predefined_assets.dart (1 hunks)
  • test/ci/fetching/assets/doge_fetch_test.dart (1 hunks)
  • test/ci/fetching/endpoint_test.dart (1 hunks)
  • test/no_ci/input_simulation_test.dart (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Static code analysis and run unit tests
🔇 Additional comments (8)
lib/src/domain/constants.dart (2)

37-39: LGTM! Address prefixes are correctly defined

The Dogecoin address prefixes are accurate:

  • 'D' for legacy addresses (P2PKH)
  • 'A' for compatibility addresses (P2SH)
  • 'dc1' for native SegWit addresses (P2WPKH)

56-65: Verify BIP prefixes for Dogecoin

The implementation uses the same prefix for BIP49 and BIP84, which is unusual. While the comments acknowledge this, we should verify this is intentional.

lib/src/domain/predefined_assets.dart (1)

31-35: LGTM! Dogecoin asset is correctly defined

The Dogecoin asset definition follows the established pattern for UTXO coins and uses the correct parameters:

  • Standard 8 decimal places
  • Correct symbol 'DOGE'
  • Proper placement in UTXO assets section
lib/src/crypto/utxo/entities/payments/p2h.dart (1)

22-23: LGTM! P2PKH prefix check for Dogecoin added correctly.

The Dogecoin P2PKH prefix check is properly integrated alongside other network prefixes.

test/no_ci/input_simulation_test.dart (1)

305-305: LGTM! Dogecoin network handling added to simulation tests.

The Dogecoin network case is correctly added to use BTCOutput, consistent with other UTXO networks like Bitcoin and Litecoin.

lib/src/crypto/network_type.dart (2)

370-395: LGTM! Dogecoin network configuration looks correct.

The network parameters are properly configured:

  • Message prefix: '\x19Dogecoin Signed Message:\n'
  • Bech32 prefix: 'dc'
  • Address prefixes: 'D' (legacy), '9' (compatibility), 'dc1' (segwit)
  • Block time: 60 seconds (1 minute)

174-177: Verify the dust threshold value for Dogecoin.

The dust threshold is set to 100000000 (1 DOGE), which is significantly higher than Bitcoin's threshold (546 satoshis). Please verify if this is the correct value according to Dogecoin's specifications.

✅ Verification successful

The Dogecoin dust threshold of 1 DOGE is correct

The higher dust threshold compared to Bitcoin (546 satoshis) is appropriate given Dogecoin's lower unit value and transaction fees. Setting it to 1 DOGE (100000000) helps prevent spam transactions while maintaining the network's accessibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for dust threshold references in Dogecoin Core
rg "dust|dustthreshold|minrelaytxfee" -g '!node_modules'

Length of output: 1183


Script:

#!/bin/bash
# Find BTC dust threshold and Dogecoin configuration
echo "=== BTC Dust Threshold ==="
rg "BTC_DUSTTRESHOLD.*=.*\(" -A 2

echo -e "\n=== Dogecoin Documentation ==="
fd -e md -e txt | grep -i "doge\|coin\|readme" | xargs cat

echo -e "\n=== Network Constants ==="
rg "const.*=.*\(" lib/src/crypto/network_type.dart

Length of output: 8466


Script:

#!/bin/bash
# Search for Dogecoin-specific documentation or comments
echo "=== Dogecoin Implementation Details ==="
rg -B 2 -A 2 "DOGE" lib/src/crypto/

echo -e "\n=== Comments about dust threshold ==="
rg -B 2 -A 2 "dust.*threshold" -i lib/src/crypto/

Length of output: 4115

lib/src/crypto/utxo/utils/send.dart (1)

470-470: LGTM! Dogecoin transaction building support added correctly.

The Dogecoin network case is properly added to both buildInput and buildOutput functions, using the appropriate BTC transaction types consistent with other UTXO networks.

Also applies to: 494-494

print(adr);
}

expect(txList.length, greaterThanOrEqualTo(0));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Strengthen the test assertion

The test only verifies that txList.length >= 0, which is a weak assertion that would pass even if the fetching fails.

Consider adding more specific assertions:

-    expect(txList.length, greaterThanOrEqualTo(0));
+    expect(txList, isNotNull);
+    expect(nodes, isNotNull);
+    expect(nodes.addresses, isNotEmpty, "Should have generated at least one address");
+    for (final tx in txList) {
+      expect(tx.networkType, equals(DogecoinNetwork));
+    }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +28 to +29
address.startsWith(P2SH_PREFIX_LTC) ||
address.startsWith(P2SH_PREFIX_DOGE)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remove Dogecoin SegWit (P2WPKH) validation

Dogecoin has not activated SegWit on mainnet, therefore the P2WPKH address validation with dc1 prefix should be removed. The P2SH validation is correct and can remain unchanged.

  • Remove P2WPKH_PREFIX_DOGE constant from lib/src/domain/constants.dart
  • Remove Dogecoin check from P2WPKH validation in lib/src/crypto/utxo/entities/payments/p2h.dart
🔗 Analysis chain

Verify Dogecoin SegWit support.

While the P2SH prefix check is correct, we should verify if Dogecoin has activated SegWit and supports P2WPKH addresses with the dc1 prefix.

Run this script to check for SegWit activation status:

Also applies to: 34-35

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if any Dogecoin addresses in the codebase use SegWit format
# and verify SegWit support in Dogecoin documentation/specifications

# Search for Dogecoin SegWit addresses
rg "dc1[a-zA-HJ-NP-Z0-9]+" -g '!node_modules'

# Search for SegWit-related constants or configurations for Dogecoin
rg "P2WPKH.*DOGE|SegWit.*Doge|Dogecoin.*SegWit" -g '!node_modules'

Length of output: 4574

Comment on lines +381 to +386
endpoints: const {
("doge.aftrek.org", 50001),
// ("electrum1.cipig.net", 10060),
// ("electrum2.cipig.net", 10060),
// ("electrum3.cipig.net", 10060),
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add more reliable Dogecoin ElectrumX endpoints.

Currently, only one active endpoint is configured (doge.aftrek.org). Consider:

  1. Uncomment and verify the cipig.net endpoints
  2. Add more reliable endpoints for redundancy

The limited number of endpoints could affect network reliability and transaction broadcasting.

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.

2 participants