mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-05 03:26:43 +00:00
add descriptions to script types
This commit is contained in:
parent
3882a4b4bd
commit
79216fac91
1 changed files with 15 additions and 9 deletions
|
@ -17,7 +17,7 @@ import static com.sparrowwallet.drongo.protocol.ScriptOpCodes.*;
|
||||||
import static com.sparrowwallet.drongo.protocol.Transaction.WITNESS_SCALE_FACTOR;
|
import static com.sparrowwallet.drongo.protocol.Transaction.WITNESS_SCALE_FACTOR;
|
||||||
|
|
||||||
public enum ScriptType {
|
public enum ScriptType {
|
||||||
P2PK("P2PK", "m/44'/0'/0'") {
|
P2PK("P2PK", "Legacy (P2PK)", "m/44'/0'/0'") {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(byte[] pubKey) {
|
public Address getAddress(byte[] pubKey) {
|
||||||
return new P2PKAddress(pubKey);
|
return new P2PKAddress(pubKey);
|
||||||
|
@ -131,7 +131,7 @@ public enum ScriptType {
|
||||||
return List.of(SINGLE);
|
return List.of(SINGLE);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
P2PKH("P2PKH", "m/44'/0'/0'") {
|
P2PKH("P2PKH", "Legacy (P2PKH)", "m/44'/0'/0'") {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(byte[] pubKeyHash) {
|
public Address getAddress(byte[] pubKeyHash) {
|
||||||
return new P2PKHAddress(pubKeyHash);
|
return new P2PKHAddress(pubKeyHash);
|
||||||
|
@ -244,7 +244,7 @@ public enum ScriptType {
|
||||||
return List.of(SINGLE);
|
return List.of(SINGLE);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MULTISIG("Bare Multisig", "m/44'/0'/0'") {
|
MULTISIG("Bare Multisig", "Bare Multisig", "m/44'/0'/0'") {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(byte[] bytes) {
|
public Address getAddress(byte[] bytes) {
|
||||||
throw new ProtocolException("No single address for multisig script type");
|
throw new ProtocolException("No single address for multisig script type");
|
||||||
|
@ -430,7 +430,7 @@ public enum ScriptType {
|
||||||
return List.of(MULTI);
|
return List.of(MULTI);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
P2SH("P2SH", "m/45'") {
|
P2SH("P2SH", "Legacy (P2SH)", "m/45'") {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(byte[] scriptHash) {
|
public Address getAddress(byte[] scriptHash) {
|
||||||
return new P2SHAddress(scriptHash);
|
return new P2SHAddress(scriptHash);
|
||||||
|
@ -555,7 +555,7 @@ public enum ScriptType {
|
||||||
return List.of(MULTI);
|
return List.of(MULTI);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
P2SH_P2WPKH("P2SH-P2WPKH", "m/49'/0'/0'") {
|
P2SH_P2WPKH("P2SH-P2WPKH", "Nested Segwit (P2SH-P2WSH)", "m/49'/0'/0'") {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(byte[] scriptHash) {
|
public Address getAddress(byte[] scriptHash) {
|
||||||
return P2SH.getAddress(scriptHash);
|
return P2SH.getAddress(scriptHash);
|
||||||
|
@ -658,7 +658,7 @@ public enum ScriptType {
|
||||||
return List.of(SINGLE);
|
return List.of(SINGLE);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
P2SH_P2WSH("P2SH-P2WSH", "m/48'/0'/0'/1'") {
|
P2SH_P2WSH("P2SH-P2WSH", "Nested Segwit (P2SH-P2WSH)", "m/48'/0'/0'/1'") {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(byte[] scriptHash) {
|
public Address getAddress(byte[] scriptHash) {
|
||||||
return P2SH.getAddress(scriptHash);
|
return P2SH.getAddress(scriptHash);
|
||||||
|
@ -759,7 +759,7 @@ public enum ScriptType {
|
||||||
return List.of(MULTI, CUSTOM);
|
return List.of(MULTI, CUSTOM);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
P2WPKH("P2WPKH", "m/84'/0'/0'") {
|
P2WPKH("P2WPKH", "Native Segwit (P2WPKH)", "m/84'/0'/0'") {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(byte[] pubKeyHash) {
|
public Address getAddress(byte[] pubKeyHash) {
|
||||||
return new P2WPKHAddress(pubKeyHash);
|
return new P2WPKHAddress(pubKeyHash);
|
||||||
|
@ -864,7 +864,7 @@ public enum ScriptType {
|
||||||
return List.of(SINGLE);
|
return List.of(SINGLE);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
P2WSH("P2WSH", "m/48'/0'/0'/2'") {
|
P2WSH("P2WSH", "Native Segwit (P2WSH)", "m/48'/0'/0'/2'") {
|
||||||
@Override
|
@Override
|
||||||
public Address getAddress(byte[] scriptHash) {
|
public Address getAddress(byte[] scriptHash) {
|
||||||
return new P2WSHAddress(scriptHash);
|
return new P2WSHAddress(scriptHash);
|
||||||
|
@ -977,10 +977,12 @@ public enum ScriptType {
|
||||||
};
|
};
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final String description;
|
||||||
private final String defaultDerivationPath;
|
private final String defaultDerivationPath;
|
||||||
|
|
||||||
ScriptType(String name, String defaultDerivationPath) {
|
ScriptType(String name, String description, String defaultDerivationPath) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
this.defaultDerivationPath = defaultDerivationPath;
|
this.defaultDerivationPath = defaultDerivationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,6 +990,10 @@ public enum ScriptType {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDefaultDerivationPath() {
|
public String getDefaultDerivationPath() {
|
||||||
return Network.get() != Network.MAINNET ? defaultDerivationPath.replace("/0'/0'", "/1'/0'") : defaultDerivationPath;
|
return Network.get() != Network.MAINNET ? defaultDerivationPath.replace("/0'/0'", "/1'/0'") : defaultDerivationPath;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue