Bitcoin Forum
November 22, 2019, 07:08:42 AM *
News: Help collect the most notable posts made over the last 10 years.
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: How does one derive a SegWit address from a legacy address? [0.001 BTC Reward!]  (Read 271 times)
Coding Enthusiast
Hero Member
*****
Offline Offline

Activity: 701
Merit: 1169


Novice C♯ Coder


View Profile WWW
March 29, 2019, 02:46:17 PM
Merited by HCP (10), LoyceV (5), poordeveloper (2), StackGambler (1)
 #21

That would be a massive help! If you can code up something that links the two addresses, or point me towards an online resource that does the job, it would be amazing. You'll get the reward as well, if you care for that sort of thing  Tongue Bless you!

Here you go. https://github.com/Coding-Enthusiast/AddrConverter (going to add ReadMe, License and release in a minute)
And don't worry about "reward".

Projects List+Suggestion box
Donation link using BIP21
Bech32 Donation link!
BitcoinTransactionTool (0.9.2):  Ann - Source Code
Watch Only Bitcoin Wallet (supporting SegWit) (3.1.0):  Ann - Source Code
SharpPusher (broadcast transactions) (0.10.0): Ann - Source Code

1574406522
Hero Member
*
Offline Offline

Posts: 1574406522

View Profile Personal Message (Offline)

Ignore
1574406522
Reply with quote  #2

1574406522
Report to moderator
The Bitcoin Forum is turning 10 years old! Join the community in sharing and exploring the notable posts made over the years.
1574406522
Hero Member
*
Offline Offline

Posts: 1574406522

View Profile Personal Message (Offline)

Ignore
1574406522
Reply with quote  #2

1574406522
Report to moderator
1574406522
Hero Member
*
Offline Offline

Posts: 1574406522

View Profile Personal Message (Offline)

Ignore
1574406522
Reply with quote  #2

1574406522
Report to moderator
StackGambler
Member
**
Offline Offline

Activity: 196
Merit: 66

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 03:01:50 PM
 #22

That would be a massive help! If you can code up something that links the two addresses, or point me towards an online resource that does the job, it would be amazing. You'll get the reward as well, if you care for that sort of thing  Tongue Bless you!

Here you go. https://github.com/Coding-Enthusiast/AddrConverter (going to add ReadMe, License and release in a minute)
And don't worry about "reward".

Thank you very much! I've never run something like this before, so I'm currently installing Visual Studio to open this up. Feel free to drop your bitcoin address anytime. If this works, I'll update the thread. I appreciate it!

Coding Enthusiast
Hero Member
*****
Offline Offline

Activity: 701
Merit: 1169


Novice C♯ Coder


View Profile WWW
March 29, 2019, 03:11:22 PM
 #23

I've added the files I mentioned above with a release which you don't have to use if you compile it yourself.
I've also added a bunch of comments in the main function to clarify what is happening. The rest of the code is also fully documented (since I copied them over from my main library project) so the functions purposes should be clear enough.

Projects List+Suggestion box
Donation link using BIP21
Bech32 Donation link!
BitcoinTransactionTool (0.9.2):  Ann - Source Code
Watch Only Bitcoin Wallet (supporting SegWit) (3.1.0):  Ann - Source Code
SharpPusher (broadcast transactions) (0.10.0): Ann - Source Code

StackGambler
Member
**
Offline Offline

Activity: 196
Merit: 66

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 03:39:01 PM
 #24

I've added the files I mentioned above with a release which you don't have to use if you compile it yourself.
I've also added a bunch of comments in the main function to clarify what is happening. The rest of the code is also fully documented (since I copied them over from my main library project) so the functions purposes should be clear enough.

Cool. I'm currently installing both VS and .NET Core.

I have a question: since a legacy address corresponds to several SegWit addresses, how does your program know which one to get? I specifically need a way to derive 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB from the 1XXX address. Is this doable?

Coding Enthusiast
Hero Member
*****
Offline Offline

Activity: 701
Merit: 1169


Novice C♯ Coder


View Profile WWW
March 29, 2019, 03:50:48 PM
 #25

I have a question: since a legacy address corresponds to several SegWit addresses, how does your program know which one to get? I specifically need a way to derive 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB from the 1XXX address. Is this doable?

As far as I understand the algorithm, there is only one possible P2SH-P2WPKH with current and only witness program version and that's what this code is giving you.

Projects List+Suggestion box
Donation link using BIP21
Bech32 Donation link!
BitcoinTransactionTool (0.9.2):  Ann - Source Code
Watch Only Bitcoin Wallet (supporting SegWit) (3.1.0):  Ann - Source Code
SharpPusher (broadcast transactions) (0.10.0): Ann - Source Code

StackGambler
Member
**
Offline Offline

Activity: 196
Merit: 66

YouTuber, gambler, and scam-buster.


View Profile
March 30, 2019, 06:16:23 AM
 #26

I have a question: since a legacy address corresponds to several SegWit addresses, how does your program know which one to get? I specifically need a way to derive 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB from the 1XXX address. Is this doable?

As far as I understand the algorithm, there is only one possible P2SH-P2WPKH with current and only witness program version and that's what this code is giving you.

https://gyazo.com/72b4eb7abbdc286520535da7cbea1648

Worked like a charm. Thank you so much!

Heisenberg_Hunter
Hero Member
*****
Offline Offline

Activity: 700
Merit: 644


Call a spade a spade


View Profile WWW
April 01, 2019, 09:42:13 AM
 #27

@Coding Enthusiast Thanks for being more precise and correcting me. I would like to clear up few more things from what I have read.

This part is false.
G is not exactly a "constant" and is not derived from the curve. G is one of the point on the curve that we have chosen as the "generator" of the curve. And that means multiplying any value from 1 to order of G yields another point (not a string of characters!!) on the curve which would be your public key. And that is the basic of asymmetric cryptography.
So, you do say that they are not constant. But from what I have read in Mastering Bitcoin Book, the author says that "G is a constant point and they are always same for all keys in bitcoin."

G is a constant point called the generator point,
Because the generator point is always the same for all bitcoin users,

This is false. Legacy transactions don't have higher size, they have higher weight.
Thanks for clearing it up. I was completely unaware of the weight, although I have read that segwits fees are calculated based on the virtual size of the tx.


.Mix coins.
 
Your BITCOIN Transaction
made Truly ANONYMOUS
 

███████
█████████████████
████████████████████████
█████████████████████████████
██████████                    ██████████
█████████                          █████████
███████                                    ████████
          ███████                                        ███████        ██
          █████████████████████████████████████      ███
          █████████████████████████████████████  █████
          ████████████████████████████████████  ██████
        ██████████████████████████████████████████
  █████████████████████████████████████████
█████                                        ████████████
                                  ██████████████
██                          █████████████████████          ██     
█████              ███████████████████████          ████     
█████████████████████████████            █████████     
██████████████████                      ████████████       
██████████████████████████████████████     
████████████████████████  ███████ 
    ██████████              █████
                      ████████
      ████████████████    █
        ██████████████████
                  █████      ███
                      █████
                    ████

Blender
 
The ULTIMATE BITCOIN Mixer
with an ADVANCED TECHNOLOGY
 

███████████   
███████████████████████   
████████████████████████████     
██████████████████████████████     
██████████████████████████████     
 

                                          █████████████
                                          ███████████
██████
                                          ███████████
██████
                                          ███████████
        ██
                                        ████████████
        ██
    ██                              █████████████
        ██
    ████                      ███████████████
        ██
    ██████              █████████████████
        ██
    █████████████████████████████
          ██ 
      ███████████████████████████
          ███
      ██████  ████████████████████
        ████
      ██████████████████████████
  ██████
      ██████████████████████████
███████
  █████      ████████████████████
███
████          ████████████████
████ 
████          ████████████████       
████████████████████████
 

   
█████████████████████████       
███████████████████████████       
█████████    ██    ███    ██████████     
███████████    ██    ███     ██████████       
███████████    ██    ███     ███████████     
██████████████████████████████████     
██████████████████████████████████       
Coding Enthusiast
Hero Member
*****
Offline Offline

Activity: 701
Merit: 1169


Novice C♯ Coder


View Profile WWW
April 01, 2019, 01:11:00 PM
 #28

This part is false.
G is not exactly a "constant" and is not derived from the curve. G is one of the point on the curve that we have chosen as the "generator" of the curve. And that means multiplying any value from 1 to order of G yields another point (not a string of characters!!) on the curve which would be your public key. And that is the basic of asymmetric cryptography.
So, you do say that they are not constant. But from what I have read in Mastering Bitcoin Book, the author says that "G is a constant point and they are always same for all keys in bitcoin."

Well, I said "not exactly" so it is somewhat correct and when I said "false" I mostly meant the second part of what I quoted.
But basically when you are talking about elliptic curves in general, G is simply a point on the curve. In a specific curve like secp256k1 which bitcoin uses, there is only one G that is used as a standard for that curve.

Projects List+Suggestion box
Donation link using BIP21
Bech32 Donation link!
BitcoinTransactionTool (0.9.2):  Ann - Source Code
Watch Only Bitcoin Wallet (supporting SegWit) (3.1.0):  Ann - Source Code
SharpPusher (broadcast transactions) (0.10.0): Ann - Source Code

Pages: « 1 [2]  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!