Skip to content

Fix/assign network to dvm address string#192

Open
secretnamebasis wants to merge 2 commits into
deroproject:community-mainnetfrom
secretnamebasis:fix/assign_network_to_dvm_address_string
Open

Fix/assign network to dvm address string#192
secretnamebasis wants to merge 2 commits into
deroproject:community-mainnetfrom
secretnamebasis:fix/assign_network_to_dvm_address_string

Conversation

@secretnamebasis

@secretnamebasis secretnamebasis commented Jul 7, 2026

Copy link
Copy Markdown

Description

Okay, to sum up - the address_string function (func dvm_address_string) uses rpc.NewAddressFromKeys, which does not evaluate IsMainntet() and assign addr.Mainnet because of cycle of imports error; and so the new address must be assigned its mainnet attribute after being created by the rpc package.

So essentially to fix this but; we have to do this:

The Fix:

dvm/dvm_functions.go

import  "github.com/deroproject/derohe/globals"

func dvm_address_string(dvm *DVM_Interpreter, expr *ast.CallExpr) (handled bool, result string) {
    checkargscount(1, len(expr.Args)) // check number of arguments

    addr_eval := dvm.eval(expr.Args[0])
    switch k := addr_eval.(type) {
    case string:
        p := new(crypto.Point)
        if err := p.DecodeCompressed([]byte(k)); err == nil {

            addr := rpc.NewAddressFromKeys(p)
            addr.Mainnet = globals.IsMainnet() // ask global state: dero / deto
            return true, addr.String()
        }

        return true, "" // fallthrough not supported in type switch
    default:
        return true, ""
    }
}

Fixes # (issue)

secretnamebasis#2 (comment)

Type of change

Please select the right one.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This will require a HardFork to be enabled

Which part is impacted ?

  • Wallet
  • Daemon
  • Miner
  • Explorer
  • Simulator
  • Misc: DVM

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

License

Im am contributing & releasing the code under DERO Research License (which can be found here).

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