mirror of
https://github.com/sparrowwallet/drongo.git
synced 2025-11-05 11:56:38 +00:00
fix npe on null p2sh redeem script
This commit is contained in:
parent
1623f923b3
commit
9c826d7819
2 changed files with 14 additions and 2 deletions
|
|
@ -16,6 +16,14 @@ public class SilentPaymentScanAddress extends SilentPaymentAddress {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ECKey getChangeTweakKey() {
|
||||||
|
return SilentPaymentUtils.getLabelledTweakKey(getScanKey(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ECKey getLabelledTweakKey(int labelIndex) {
|
||||||
|
return SilentPaymentUtils.getLabelledTweakKey(getScanKey(), labelIndex);
|
||||||
|
}
|
||||||
|
|
||||||
public SilentPaymentScanAddress getChangeAddress() {
|
public SilentPaymentScanAddress getChangeAddress() {
|
||||||
return getLabelledAddress(0);
|
return getLabelledAddress(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public class SilentPaymentUtils {
|
||||||
break;
|
break;
|
||||||
case P2SH:
|
case P2SH:
|
||||||
Script redeemScript = input.getScriptSig().getFirstNestedScript();
|
Script redeemScript = input.getScriptSig().getFirstNestedScript();
|
||||||
if(ScriptType.P2WPKH.isScriptType(redeemScript)) {
|
if(redeemScript != null && ScriptType.P2WPKH.isScriptType(redeemScript)) {
|
||||||
if(input.getWitness() != null && input.getWitness().getPushCount() == 2) {
|
if(input.getWitness() != null && input.getWitness().getPushCount() == 2) {
|
||||||
byte[] pubKey = input.getWitness().getPushes().getLast();
|
byte[] pubKey = input.getWitness().getPushes().getLast();
|
||||||
if(pubKey != null && pubKey.length == 33) {
|
if(pubKey != null && pubKey.length == 33) {
|
||||||
|
|
@ -270,8 +270,12 @@ public class SilentPaymentUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ECKey getLabelledSpendKey(ECKey scanPrivateKey, ECKey spendPublicKey, int labelIndex) {
|
public static ECKey getLabelledSpendKey(ECKey scanPrivateKey, ECKey spendPublicKey, int labelIndex) {
|
||||||
|
return spendPublicKey.add(getLabelledTweakKey(scanPrivateKey, labelIndex), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ECKey getLabelledTweakKey(ECKey scanPrivateKey, int labelIndex) {
|
||||||
BigInteger labelTweak = new BigInteger(1, Utils.taggedHash(BIP_0352_LABEL_TAG,
|
BigInteger labelTweak = new BigInteger(1, Utils.taggedHash(BIP_0352_LABEL_TAG,
|
||||||
Utils.concat(scanPrivateKey.getPrivKeyBytes(), ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(labelIndex).array())));
|
Utils.concat(scanPrivateKey.getPrivKeyBytes(), ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(labelIndex).array())));
|
||||||
return spendPublicKey.add(ECKey.fromPublicOnly(ECKey.publicPointFromPrivate(labelTweak).getEncoded(true)), true);
|
return ECKey.fromPublicOnly(ECKey.publicPointFromPrivate(labelTweak).getEncoded(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue