diff --git a/src/main/java/com/sparrowwallet/drongo/crypto/ECKey.java b/src/main/java/com/sparrowwallet/drongo/crypto/ECKey.java index be966e0..7f729fd 100644 --- a/src/main/java/com/sparrowwallet/drongo/crypto/ECKey.java +++ b/src/main/java/com/sparrowwallet/drongo/crypto/ECKey.java @@ -275,6 +275,16 @@ public class ECKey { * use {@code new BigInteger(1, bytes);} */ public static ECPoint publicPointFromPrivate(BigInteger privKey) { + if(Secp256k1Context.isEnabled()) { + try { + byte[] pubKeyBytes = NativeSecp256k1.computePubkey(Utils.bigIntegerToBytes(privKey, 32), false); + LazyECPoint lazyECPoint = new LazyECPoint(CURVE.getCurve(), pubKeyBytes); + return lazyECPoint.get(); + } catch(NativeSecp256k1Util.AssertFailException e) { + log.error("Error computing public key from private", e); + } + } + /* * TODO: FixedPointCombMultiplier currently doesn't support scalars longer than the group order, * but that could change in future versions. diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index 11c3e08..d69755f 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -924,8 +924,8 @@ public class Wallet extends Persistable implements Comparable { * @return the number of weight units (WU) */ public int getInputWeightUnits() { - //Estimate assuming an input spending from a fresh receive node - it does not matter this node has no real utxos - WalletNode receiveNode = getFreshNode(KeyPurpose.RECEIVE); + //Estimate assuming an input spending from the parent receive node - it does not matter this node has no real utxos + WalletNode receiveNode = new WalletNode(this, KeyPurpose.RECEIVE); Transaction transaction = new Transaction(); TransactionOutput prevTxOut = transaction.addOutput(1L, receiveNode.getAddress());