Stacks.js: CLI: Convert testnet to mainnet address

Created on 20 Jan 2021  路  3Comments  路  Source: blockstack/stacks.js

The current CLI convert_address command returns the same addresses for both networks if it is used with a testnet address. It seems that only mainnet addresses can be converted to testnet addresses.

A fix for this should also include an update of the docs inside the CLI (see https://docs.blockstack.org/references/stacks-cli#convert_address)

stacks convert_address ST6KSMBVZZ9YCP3PEX3FN71YQQEGB7RKTYPC51YX -t
{
  "mainnet": {
    "STACKS": "ST6KSMBVZZ9YCP3PEX3FN71YQQEGB7RKTYPC51YX",
    "BTC": "mgiwwH2yfnngqs8xfm443p1EqFHMWUx3rM"
  },
  "testnet": {
    "STACKS": "ST6KSMBVZZ9YCP3PEX3FN71YQQEGB7RKTYPC51YX",
    "BTC": "mgiwwH2yfnngqs8xfm443p1EqFHMWUx3rM"
  }
}
bug

Most helpful comment

I think the current behavior with the following addition would be ideal

For the last example, maybe the intend of a user would be to find the associated btc address for testnet?

So you'll get testnet output whether -t arg was passed or if the address is a testnet address

$ stx convert_address STA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7DX96QAM
{
  "mainnet": {
    "STACKS": "SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW",
    "BTC": "12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD"
  },
  "testnet": {
    "STACKS": "STA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7DX96QAM",
    "BTC": "mhMaijcwVPcdAthFwmgLsaknTRt72GqQYo"
  }
}

All 3 comments

@agraebe

This should be the expected result, correct?

$ stx convert_address 12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD
{
  "mainnet": {
    "STACKS": "SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW",
    "BTC": "12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD"
  }
}

$ stx convert_address SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW
{
  "mainnet": {
    "STACKS": "SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW",
    "BTC": "12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD"
  }
}

$ stx convert_address SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW -t
{
  "mainnet": {
    "STACKS": "SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW",
    "BTC": "12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD"
  },
  "testnet": {
    "STACKS": "STA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7DX96QAM",
    "BTC": "mhMaijcwVPcdAthFwmgLsaknTRt72GqQYo"
  }
}

$ stx convert_address STA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7DX96QAM
{
  "mainnet": {
    "STACKS": "SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW",
    "BTC": "12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD"
  }
}

I believe so, even though I'd open up a conversation to make this command more "intuitive". It does a few things implicitly:

  • use a btc OR a stx address as input
  • convert a testnet stx address to mainnet, without a parameter
  • show the mainnet response object for testnet input

For the last example, maybe the intend of a user would be to find the associated btc address for testnet?

What are your thoughts? We can hold off on big changes but thinking about the ideal behavior would be helpful IMHO

I think the current behavior with the following addition would be ideal

For the last example, maybe the intend of a user would be to find the associated btc address for testnet?

So you'll get testnet output whether -t arg was passed or if the address is a testnet address

$ stx convert_address STA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7DX96QAM
{
  "mainnet": {
    "STACKS": "SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW",
    "BTC": "12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD"
  },
  "testnet": {
    "STACKS": "STA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7DX96QAM",
    "BTC": "mhMaijcwVPcdAthFwmgLsaknTRt72GqQYo"
  }
}
Was this page helpful?
0 / 5 - 0 ratings