Bitcoin Forum
May 21, 2024, 06:36:02 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin development tapscript C# seemingly unsolvable task  (Read 94 times)
warpanomaly (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 25


View Profile
May 01, 2024, 04:55:17 AM
 #1

Hi guys, I made this post on Bitcointalk a while ago:


Quote
I have a script that works perfectly in creating an inscription taproot address with Javascript https://gist.github.com/ChristianOConnor/fa07462990a74606f486f97031783e50. I committed the private key and inscription text to the code. There's nothing in the wallet so it shouldn't be a security problem. The address outputted by the script is tb1pzr0236kw9vnavfl6zjk4xvfsvptfwq2202newug2se5tsg2fmrhsa4hv7z.

Again, I've tested the javascript code including spending an inscription output and it works perfectly. I unsuccessfully tried porting the above script to C#. It doesn't produce the correct address. This is the C# script https://gist.github.com/ChristianOConnor/2399a864f38666a2a3305b9ad7d374d1 preloaded with the same private key and inscription string. It incorrectly produces this address: tb1p90cf5jsmvv2cwu7wq2k60pewtpu5xvlfypxwjeag4aq9yhaccgks68fc8j.

Can anyone fix my C# script so that it produces the correct address aka tb1pzr0236kw9vnavfl6zjk4xvfsvptfwq2202newug2se5tsg2fmrhsa4hv7z.

This would be unpaid, but if you can fix the C# script I'll open source it and MIT license the code. P.S. Could you please perpetually MIT license your fix for the C# script.



I thought it was a going to be a simple task but OMG I was wrong. I'm trying to create a Bitcoin inscription with C#. I've found libraries that can do this in Javascript and a few other languages but non in C#. I can't find an example. I made a script that ALMOST does this but I get a signature error.

Btw, I know that creating Bitcoin inscriptions or anything that could be considered similar to an ordinal or BRC-20 is somewhat controversial but that's not the goal here. I want to create an inscription to build an app that requires a TINY AMOUNT of "hard" storage stored in the form of an inscription. It's SUPER TINY (literally the size of a sha-256 hash) and not going to clog up Bitcoin but I just can't find anyone that can help me fix the bug in my script. Does anyone know how to make by C# script work like my Javascript script does?

And I don't need open time stamps. This project is different.
ABCbits
Legendary
*
Offline Offline

Activity: 2884
Merit: 7510


Crypto Swap Exchange


View Profile
May 01, 2024, 12:18:31 PM
Merited by pooya87 (4)
 #2

Btw, I know that creating Bitcoin inscriptions or anything that could be considered similar to an ordinal or BRC-20 is somewhat controversial but that's not the goal here. I want to create an inscription to build an app that requires a TINY AMOUNT of "hard" storage stored in the form of an inscription. It's SUPER TINY (literally the size of a sha-256 hash) and not going to clog up Bitcoin but I just can't find anyone that can help me fix the bug in my script. Does anyone know how to make by C# script work like my Javascript script does?

Since you only want to include output of SHA-256 hash (which have size 256-bit or 32-byte), you better use OP_RETURN. I didn't do any research, but i expect there should be C# library which let you create Bitcoin TX with OP_RETURN support since OP_RETURN has been around for 10+ years.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
warpanomaly (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 25


View Profile
May 01, 2024, 07:50:01 PM
 #3

Btw, I know that creating Bitcoin inscriptions or anything that could be considered similar to an ordinal or BRC-20 is somewhat controversial but that's not the goal here. I want to create an inscription to build an app that requires a TINY AMOUNT of "hard" storage stored in the form of an inscription. It's SUPER TINY (literally the size of a sha-256 hash) and not going to clog up Bitcoin but I just can't find anyone that can help me fix the bug in my script. Does anyone know how to make by C# script work like my Javascript script does?

Since you only want to include output of SHA-256 hash (which have size 256-bit or 32-byte), you better use OP_RETURN. I didn't do any research, but i expect there should be C# library which let you create Bitcoin TX with OP_RETURN support since OP_RETURN has been around for 10+ years.


I already know about OP_RETURN, but unfortunately I can't use it for this project. The app requires the string to be read with the ordinal envelope aka: 
Code:
OP_FALSE 
OP_IF
   OP_PUSH "ord"
   OP_PUSH 1
   OP_PUSH "text/plain;charset=utf-8"
   OP_PUSH 0
   OP_PUSH "Hello, world!"
 OP_ENDIF
 

But obviously instead of "Hello world!", it will be the SHA256 hash. I'm taking advantage of an ordinal block explorer to by giving the envelope the ordinal identifier "ord" so the SHA256 hash is picked up on the ordinal block explorer where my app can read the hash. 

Even though I am using the ordinal envelope and using an ordinal block explorer to read the data, this is not an ordinal in a traditional sense. Every user on my app will write 1 ordinal as a registering function for my app. It will not clog up the bitcoin blockchain and will not spam the bitcoin network. Gas fees will not go up because of my app, don't worry. 

So does anybody know how to fix my C# script so it works like my Javascript script does?
pooya87
Legendary
*
Offline Offline

Activity: 3458
Merit: 10572



View Profile
May 02, 2024, 05:38:21 AM
 #4

Every user on my app will write 1 ordinal as a registering function for my app. It will not clog up the bitcoin blockchain and will not spam the bitcoin network. Gas fees will not go up because of my app, don't worry. 
Bitcoin blockchain is not meant for data storage and Bitcoin is not a cloud storage. It is a payment system and the blockchain is ledger for monetary transactions. So it doesn't matter if it is 1 byte or 1 terabyte that you are injecting into the chain by using the exploit in the protocol, it is still abusive.

So use OP_RETURN instead as @ABCbits said or better yet use one of those data-storage altcoins. There are a couple of them that are created for this exact purpose.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NotATether
Legendary
*
Offline Offline

Activity: 1610
Merit: 6752


bitcoincleanup.com / bitmixlist.org


View Profile WWW
May 02, 2024, 07:49:19 AM
 #5

Have you verified that your transaction creation functions are working fine for other types of transactions and that it is just the TapScript code that's causing errors?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
warpanomaly (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 25


View Profile
May 02, 2024, 09:35:25 AM
 #6

Quote
Have you verified that your transaction creation functions are working fine for other types of transactions and that it is just the TapScript code that's causing errors?
 

Yeah I have a more complex version of each script that creates the inscription address, I send a BTC transaction to that address, then the script spends the UTXO that I sent the address. The Javascript scripts works perfectly and creates an inscription when I spend along the script path of the freshly created address. The C# script fails with a signature error when I try to spend from the script path of the freshly created address.

My C# script works fine spending along the address keypath, but not the script keypath. Looking at the output transactions from the Javacript script and C# script, I've narrowed it down to the the tapscript not being created correctly in the C# script.
ABCbits
Legendary
*
Offline Offline

Activity: 2884
Merit: 7510


Crypto Swap Exchange


View Profile
May 02, 2024, 10:03:00 AM
 #7

I'm taking advantage of an ordinal block explorer to by giving the envelope the ordinal identifier "ord" so the SHA256 hash is picked up on the ordinal block explorer where my app can read the hash.

And regular block explorer can show OP_RETURN data.

Even though I am using the ordinal envelope and using an ordinal block explorer to read the data, this is not an ordinal in a traditional sense. Every user on my app will write 1 ordinal as a registering function for my app. It will not clog up the bitcoin blockchain and will not spam the bitcoin network. Gas fees will not go up because of my app, don't worry. 

Bitcoin user will be impacted if your application is popular enough. And if your application is centralized, i don't understand why you chose not to use either email address or phone number.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!