Skip to content

Add Digiwage Support#1121

Open
gdiscord wants to merge 1 commit intotrezor:masterfrom
gdiscord:master
Open

Add Digiwage Support#1121
gdiscord wants to merge 1 commit intotrezor:masterfrom
gdiscord:master

Conversation

@gdiscord
Copy link
Copy Markdown

@gdiscord gdiscord commented Aug 7, 2024

Build - successful
Unit test and Integration test - both successful

explorer url: https://wagescan.digiwage.org

digiwage_blockbook_image

make test-integration ARGS="-run=TestIntegration/digiwage/"
Image blockbook-build is up to date
docker run -t --rm -e PACKAGER=0:0 -v "/root/Temp/blockbook:/src" --network="host" blockbook-build make test-integration ARGS="-run=TestIntegration/digiwage/"
rm -rf /go/src/github.com/trezor/blockbook
mkdir -p /go/src/github.com/trezor
cp -r /src /go/src/github.com/trezor/blockbook
cd /go/src/github.com/trezor/blockbook && go mod download
sed -i 's/wsMessageSizeLimit\ =\ 15\ \*\ 1024\ \*\ 1024/wsMessageSizeLimit = 80 * 1024 * 1024/g' /go/pkg/mod/github.com/ava-labs/coreth*/rpc/websocket.go
cd /go/src/github.com/trezor/blockbook && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` -run=TestIntegration/digiwage/
?   	github.com/trezor/blockbook/tests/dbtestdata	[no test files]
?   	github.com/trezor/blockbook/tests/rpc	[no test files]
?   	github.com/trezor/blockbook/tests/sync	[no test files]
ok  	github.com/trezor/blockbook/tests	0.346s 

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds Digiwage (WAGE) coin support by introducing its RPC implementation, parser, configuration, and associated test data and unit/integration tests.

  • Adds Digiwage RPC and parser with custom handling (Zerocoin scripts, shielded tx structure, block version nuances).
  • Introduces coin configuration and registers Digiwage in blockchain factory map.
  • Adds test fixtures and unit tests for address/script handling, tx packing/unpacking, and block parsing.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
configs/coins/digiwage.json Adds runtime configuration for Digiwage (ports, backend binary, slip44, xpub magic, etc.).
bchain/coins/blockchain.go Registers Digiwage RPC factory.
bchain/coins/digiwage/digiwagerpc.go Implements Digiwage-specific RPC wrapper and initialization.
bchain/coins/digiwage/digiwageparser.go Implements Digiwage parser with Zerocoin and shielded tx handling.
bchain/coins/digiwage/digiwageparser_test.go Adds unit tests for address/script parsing and tx/block serialization.
bchain/coins/digiwage/testdata/block_dump.11962 Raw block fixture for parser tests.
tests/tests.json Adds Digiwage to integration test matrix.
tests/rpc/testdata/digiwage.json RPC fixture for Digiwage (block/tx data).
tests/sync/testdata/digiwage.json Sync test fixture for block processing and fork handling.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}
],
"blockhash": "25961563bc9afae2b7ed3bc8dc61da40185bbe86096d687f746c632a885a1e01",
"confirmations": 2553878,
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

Both transactions are in the same block (same blockhash and time) but have different confirmation counts, which is internally inconsistent. Use the same deterministic value (e.g. 1) or omit confirmations in fixtures to avoid misleading or brittle tests.

Suggested change
"confirmations": 2553878,

Copilot uses AI. Check for mistakes.
],
"hex": "01000000018090210721792f1af27ffa402460b0826b29785d47e7704cfa89e50fc714d9380100000049483045022100a69bf16bbeda76dbeb22541714f640ad2c98f530560b9090848c63b718ef4aba02203fc5be3622bdad8316b502e405d62871ffba0e57c41f5b43fdc7047f793b924f01ffffffff03000000000000000000cb25ac0f3c0000002321030e55883d14ce52ba7b3ab23a61dfc50241333a8ee748029ec849ac036676b1d9ac00286bee000000001976a9142ccad575530bcb760a9365820b837787928390fd88ac00000000",
"blockhash": "25961563bc9afae2b7ed3bc8dc61da40185bbe86096d687f746c632a885a1e01",
"confirmations": 2553889,
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

Both transactions are in the same block (same blockhash and time) but have different confirmation counts, which is internally inconsistent. Use the same deterministic value (e.g. 1) or omit confirmations in fixtures to avoid misleading or brittle tests.

Suggested change
"confirmations": 2553889,
"confirmations": 1,

Copilot uses AI. Check for mistakes.
"blockhash": "25961563bc9afae2b7ed3bc8dc61da40185bbe86096d687f746c632a885a1e01",
"time": 1536318380,
"blocktime": 1536318380,
"confirmations": 0
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

Transaction includes blockhash and block metadata yet confirmations is 0, which contradicts a confirmed state. Set this to a positive value (e.g. 1) or remove the field if not asserted in tests.

Suggested change
"confirmations": 0
"confirmations": 1

Copilot uses AI. Check for mistakes.
"system_user": "blockbook-digiwage",
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
"explorer_url": "",
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

[nitpick] explorer_url is empty but the PR description provides https://wagescan.digiwage.org; populating it improves discoverability and parity with other coin configs.

Suggested change
"explorer_url": "",
"explorer_url": "https://wagescan.digiwage.org",

Copilot uses AI. Check for mistakes.
if txCount > maxTxPerBlock {
str := fmt.Sprintf("too many transactions to fit into a block "+
"[count %d, max %d]", txCount, maxTxPerBlock)
return &wire.MessageError{Func: "utils.decodeTransactions", Description: str}
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The Func field references 'utils.decodeTransactions' which does not match the actual function name (DigiwageDecodeTransactions), reducing traceability. Update the string to 'DigiwageDecodeTransactions' for accurate error provenance.

Suggested change
return &wire.MessageError{Func: "utils.decodeTransactions", Description: str}
return &wire.MessageError{Func: "DigiwageDecodeTransactions", Description: str}

Copilot uses AI. Check for mistakes.
name := fmt.Sprintf("block_dump.%d", height)
path := filepath.Join("testdata", name)

d, err := ioutil.ReadFile(path)
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

ioutil.ReadFile is deprecated; replace with os.ReadFile for current Go versions.

Suggested change
d, err := ioutil.ReadFile(path)
d, err := os.ReadFile(path)

Copilot uses AI. Check for mistakes.
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