mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 05:27:17 +00:00
Receive to and send from native segwit addresses
- Hierarchical-deterministic derivation of native segwit addresses. - Receive payments to native segwit addresses. - Spend and sign payments from native segwit addresses. - Watch-only wallets with native segwit addresses (zpub/vpub). - WalletAppKit, Wallet-tool and Wallet-template are taught to deal with segwit-enabled wallets. Be aware this adds a new field in the wallet protobuf: output_script_type in Key, which keeps track of the script type of DeterministicKeyChains. Protobufs will be migrated; old DeterministicKeyChains are assumed to be of type P2PKH. Includes some code by Fabrice Drouin.
This commit is contained in:
@@ -22,6 +22,7 @@ import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Utils;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.*;
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.bitcoinj.utils.Threading;
|
||||
import org.bitcoinj.wallet.DeterministicSeed;
|
||||
@@ -46,6 +47,7 @@ import static wallettemplate.utils.GuiUtils.*;
|
||||
|
||||
public class Main extends Application {
|
||||
public static NetworkParameters params = MainNetParams.get();
|
||||
public static final Script.ScriptType PREFERRED_OUTPUT_SCRIPT_TYPE = Script.ScriptType.P2WPKH;
|
||||
public static final String APP_NAME = "WalletTemplate";
|
||||
private static final String WALLET_FILE_NAME = APP_NAME.replaceAll("[^a-zA-Z0-9.-]", "_") + "-"
|
||||
+ params.getPaymentProtocolId();
|
||||
@@ -132,7 +134,7 @@ public class Main extends Application {
|
||||
|
||||
public void setupWalletKit(@Nullable DeterministicSeed seed) {
|
||||
// If seed is non-null it means we are restoring from backup.
|
||||
bitcoin = new WalletAppKit(params, new File("."), WALLET_FILE_NAME) {
|
||||
bitcoin = new WalletAppKit(params, PREFERRED_OUTPUT_SCRIPT_TYPE, null, new File("."), WALLET_FILE_NAME) {
|
||||
@Override
|
||||
protected void onSetupCompleted() {
|
||||
// Don't make the user wait for confirmations for now, as the intention is they're sending it
|
||||
|
||||
@@ -58,6 +58,7 @@ public class SendMoneyController {
|
||||
new TextFieldValidator(amountEdit, text ->
|
||||
!WTUtils.didThrow(() -> checkState(Coin.parseCoin(text).compareTo(balance) <= 0)));
|
||||
amountEdit.setText(balance.toPlainString());
|
||||
address.setPromptText(Address.fromKey(Main.params, new ECKey(), Main.PREFERRED_OUTPUT_SCRIPT_TYPE).toString());
|
||||
}
|
||||
|
||||
public void cancel(ActionEvent event) {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TextField fx:id="address" maxWidth="1.7976931348623157E308" promptText="1EZEqFBd8yuc9ir2761987q7k3VcALC8YQ" HBox.hgrow="ALWAYS">
|
||||
<TextField fx:id="address" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS">
|
||||
<VBox.margin>
|
||||
<Insets />
|
||||
</VBox.margin>
|
||||
|
||||
Reference in New Issue
Block a user