jcnelson / naka3.sh

GNU General Public License v3.0
1 stars 1 forks source link

`stack-tx` Operation Failing Due to Address Compatibility #1

Open moodmosaic opened 4 weeks ago

moodmosaic commented 4 weeks ago

The stack-tx operation in the naka3.sh script consistently fails (in make_stacking_tx) with the following error:

stack stackity stack-stack-stack
Only support testnet p2pkh

I think, the failure occurs because the provided PoX address has a version byte of 8d (instead of 6f?)

Binary Versions:

blockstack-cli
  develop (09c4b066e25104be8b066e8f7530ff0c6df4ccd5)

stacks-signer
  develop (09c4b066e25104be8b066e8f7530ff0c6df4ccd5)

stacks-node
  develop (09c4b066e25104be8b066e8f7530ff0c6df4ccd5)

bitcoind
  25.0.0

bitcoin-cli
  25.0.0

jq
  1.6.0

dc
  1.4.1

/cc @wileyj

wileyj commented 4 weeks ago

with a test script, it seems to work fine:

addr=mkcL5EbpxqYtf1VHtrmBKgJ5aTfMttduUG #https://github.com/jcnelson/naka3.sh/blob/db72d0a536f30d1c85e935a33fbb2cd046a6234f/config.sh#L30
function b58_decode() {
   local base58_chars="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxy"
   local b58text="$1"
   if [[ "$b58text" =~ ^(1*)([$base58_chars]+)$ ]]; then
      dc -e "${BASH_REMATCH[1]//1/0P} 0${base58_chars//?/ds&1+} 0${BASH_REMATCH[2]//?/ 58*l&+}P" | hex_encode
   else
      return 1
   fi
}
function hex_encode() {
   od -An -v -tx1 | tr -d ' \n'
}
function b58_address_decode() {
   local addr="$1"
   b58_decode "$addr" | sed -r 's/^([0-9a-f]{2})([0-9a-f]{40}).+$/\1 \2#/g' | tr '#' '\n'
}
b58_decode "$addr" | sed -r 's/^([0-9a-f]{2})([0-9a-f]{40}).+$/\1 \2#/g' | tr '#' '\n'
pox_address=$addr
address_parts="$(b58_address_decode "$pox_address")"
address_version="$(echo "$address_parts" | cut -d ' ' -f 1)"

echo "address_parts: $address_parts"
echo "address_version: $address_version"

if [ "$address_version" != "6f" ]; then
    echo "Only support testnet p2pkh"
fi
$ bash t
6f 37dce38faf7956918d6bd3c026cc8a628246dedc
address_parts: 6f 37dce38faf7956918d6bd3c026cc8a628246dedc
address_version: 6f

can this be reproduced? I'm wondering if a variable is getting overwritten somewhere maybe

wileyj commented 3 weeks ago

update: this seems to be a version difference between linux's GNU dc and what macos is using.

let's keep this open for now, it would be nice to find a solution that works for both, but we're unblocked by only running on linux