I will be working on signing/spending next. To-dos: - test case for manual wallet migration - nice to have: automatic wallet migration via the already existing wallet maintenance facility - segwit watching wallets (zpub) - nice to have: segwit spending wallets, married wallets, etc.
On 04/18/2018 07:49 PM, Vadym Ustymenko wrote: > Hi Andreas > > Has there been any progress on implementing ability to spend coins from > Segwit addresses? Also, could you share any other outstanding work to be > done before full segwit support? > > Thanks! > > On Friday, March 9, 2018 at 2:31:00 AM UTC-8, Andreas Schildbach wrote: > > I'm happy to announce that current master now has full support for > sending to native Segwit addresses (BIP173). > > For app developers who depend on bitcoinj, not much should change. > However, there are some API differences: > > The Address class now has two subclasses: SegwitAddress and > LegacyAddress. Most of the bitcoinj API continues to use the Address > class so it is already prepared for further coming segwit changes. > > If you need to parse addresses (e.g. from user input), you need to > change the previous Address.fromBase58() to > > - Address.fromString() if you want your app to understand all > address types. > - LegacyAddress.fromBase58() if for some reason you want your app to > stay limited to legacy addresses. > - SegwitAddress.fromBech32() if your app should only support native > segwit addresses. > > If you're still using the new Address() constructor you need to migrate > to any of the available static constructors, including the above. All > address constructors are now either deprecated or have been made > private. > > If you are using address.toBase58() that method only exists for > addresses of type LegacyAddress. You should consider using > toString() in > future, which supports Bech32 just as it has supported Base58. > > Very similar: use address.getHash() rather than getHash160(). > > AddressFormatException now has several new subclasses to make the kind > of error more clear: > > - AddressFormatException.InvalidCharacter (the invalid char and its > position in the string is available as fields) > - AddressFormatException.InvalidDataLength > - AddressFormatException.InvalidChecksum > - AddressFormatException.InvalidPrefix (prefix means either version > header for Base58 or human-readable part for Bech32) > - and the already existing AddressFormatException.WrongNetwork if you > expect a certain network but the prefix indicates another one > > Transaction.toString() and Wallet.toString() now also print the > types of > output scripts and 'to address' for each transaction output. > > Let me know how converting your app for Segwit addresses worked for > you. > Feedback welcome! > > > Some words about the future: > > I already experimented with *receiving* coins to Segwit addresses. It's > already working, no further changes (e.g. to bloom filters) necessary! > However, be warned: you are not able to spend such coins so they > will be > stuck in your wallet. At least on master, there is no support for the > new transaction format (incl. witnesses) and signing. I'll try to > extract the necessary changes from the segwit branch, but if > somebody is > quicker please beat me at it! > > P2SH-P2WPKH: I'm not sure if we should invest much time into this. You > can of course send to P2SH since ages (v0.11), so sending to > P2SH-P2WPKH > already works in all relevant released versions of bitcoinj. When it > comes to receiving, I'm playing with the thought of skipping > P2SH-P2WPKH > and directly go for native Segwit. Electrum has taken this approach > too. > > -- > You received this message because you are subscribed to the Google > Groups "bitcoinj" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to bitcoinj+unsubscr...@googlegroups.com > <mailto:bitcoinj+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "bitcoinj" group. To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.