diff --git a/android/src/main/kotlin/africa/ejara/trustdart/Coin.kt b/android/src/main/kotlin/africa/ejara/trustdart/Coin.kt index 3b631e7..f8f5b17 100644 --- a/android/src/main/kotlin/africa/ejara/trustdart/Coin.kt +++ b/android/src/main/kotlin/africa/ejara/trustdart/Coin.kt @@ -44,13 +44,13 @@ open class Coin(nameOfCoin: String, typeOfCoin: CoinType) : CoinInterface { override fun getRawPrivateKey(path: String, mnemonic: String, passphrase: String): ByteArray? { val wallet = HDWallet(mnemonic, passphrase) return wallet.getKey(coinType, path).data() - } + } override fun getPublicKey(path: String, mnemonic: String, passphrase: String): String? { val wallet = HDWallet(mnemonic, passphrase) return wallet.getKey(coinType, path).getPublicKeySecp256k1(true).data().base64String() } - + override fun getRawPublicKey(path: String, mnemonic: String, passphrase: String): ByteArray? { val wallet = HDWallet(mnemonic, passphrase) return wallet.getKey(coinType, path).getPublicKeySecp256k1(true).data() @@ -84,7 +84,6 @@ open class Coin(nameOfCoin: String, typeOfCoin: CoinType) : CoinInterface { } override fun multiSignTransaction( - path: String, txData: Map, privateKeys: ArrayList ): String? { diff --git a/android/src/main/kotlin/africa/ejara/trustdart/TrustdartPlugin.kt b/android/src/main/kotlin/africa/ejara/trustdart/TrustdartPlugin.kt index a230af7..f9984c6 100644 --- a/android/src/main/kotlin/africa/ejara/trustdart/TrustdartPlugin.kt +++ b/android/src/main/kotlin/africa/ejara/trustdart/TrustdartPlugin.kt @@ -56,7 +56,7 @@ class TrustdartPlugin : FlutterPlugin, MethodCallHandler { validator.details.errorMessage, validator.details.errorDetails ) - } + } "checkMnemonic" -> { val mnemonic: String? = call.argument("mnemonic") val passphrase: String? = call.argument("passphrase") @@ -166,19 +166,18 @@ class TrustdartPlugin : FlutterPlugin, MethodCallHandler { } "multiSignTransaction" -> { val coin: String? = call.argument("coin") - val path: String? = call.argument("path") val txData: Map? = call.argument("txData") val privateKeys: ArrayList? = call.argument("privateKeys") var validator = WalletHandler().validate( WalletError( WalletHandlerErrorCodes.ArgumentsNull, - "[path], [coin], [privateKeys] and [txData] are required.", + "[coin], [privateKeys] and [txData] are required.", null - ), arrayOf(path, coin, txData, privateKeys) + ), arrayOf(coin, txData, privateKeys) ) if (validator.isValid) { val txHash = WalletHandler().getCoin(coin) - .multiSignTransaction(path!!, txData!!, privateKeys!!) + .multiSignTransaction(txData!!, privateKeys!!) validator = WalletHandler().validate( WalletError( WalletHandlerErrorCodes.TxHashNull, diff --git a/android/src/main/kotlin/africa/ejara/trustdart/coins/BTC.kt b/android/src/main/kotlin/africa/ejara/trustdart/coins/BTC.kt index 8ddee25..3c35715 100644 --- a/android/src/main/kotlin/africa/ejara/trustdart/coins/BTC.kt +++ b/android/src/main/kotlin/africa/ejara/trustdart/coins/BTC.kt @@ -10,7 +10,7 @@ import wallet.core.jni.CoinType import wallet.core.jni.HDWallet import wallet.core.jni.proto.Bitcoin - + class BTC : Coin("BTC", CoinType.BITCOIN) { @@ -82,7 +82,6 @@ class BTC : Coin("BTC", CoinType.BITCOIN) { override fun multiSignTransaction( - path: String, txData: Map, privateKeys: ArrayList ): String? { diff --git a/android/src/main/kotlin/africa/ejara/trustdart/interfaces/CoinInterface.kt b/android/src/main/kotlin/africa/ejara/trustdart/interfaces/CoinInterface.kt index 74b7b5d..a7e556b 100644 --- a/android/src/main/kotlin/africa/ejara/trustdart/interfaces/CoinInterface.kt +++ b/android/src/main/kotlin/africa/ejara/trustdart/interfaces/CoinInterface.kt @@ -1,5 +1,5 @@ package africa.ejara.trustdart.interfaces - + import com.google.protobuf.ByteString interface CoinInterface { @@ -13,7 +13,6 @@ interface CoinInterface { fun signDataWithPrivateKey(path: String, mnemonic: String, passphrase: String, txData: String): String? fun signTransaction(path: String, txData: Map, mnemonic: String, passphrase: String): String? fun multiSignTransaction( - path: String, txData: Map, privateKeys: ArrayList ): String? diff --git a/example/lib/operations.dart b/example/lib/operations.dart index a179493..bae9268 100644 --- a/example/lib/operations.dart +++ b/example/lib/operations.dart @@ -306,7 +306,7 @@ runOperations() async { bool valid = await Trustdart.validateAddress( coin.code, address['legacy']!, - ); + ); print([valid]); bool invalid = await Trustdart.validateAddress( @@ -330,7 +330,6 @@ runOperations() async { String multiTxSign = await Trustdart.multiSignTransaction( dondo, coin.code, - coin.path, operations[coin.code], operations[coin.code]["privateKeys"]); print('MultiSig Transaction Check ...'); diff --git a/ios/Classes/Coin.swift b/ios/Classes/Coin.swift index 0a9e5c0..5ed68c5 100644 --- a/ios/Classes/Coin.swift +++ b/ios/Classes/Coin.swift @@ -15,7 +15,7 @@ class Coin: CoinProtocol { init(name: String, coinType: CoinType){ self.name = name self.coinType = coinType - } + } func getName() -> String { return self.name @@ -82,7 +82,7 @@ class Coin: CoinProtocol { - func multiSignTransaction(path: String, txData: [String: Any], privateKeys: [String]) -> String? { + func multiSignTransaction(txData: [String: Any], privateKeys: [String]) -> String? { let opJson = Utils.objToJson(from: txData) var signatures = [String]() diff --git a/ios/Classes/SwiftTrustdartPlugin.swift b/ios/Classes/SwiftTrustdartPlugin.swift index 2151b46..b6d71d8 100644 --- a/ios/Classes/SwiftTrustdartPlugin.swift +++ b/ios/Classes/SwiftTrustdartPlugin.swift @@ -15,7 +15,7 @@ public class SwiftTrustdartPlugin: NSObject, FlutterPlugin { let wallet = WalletHandler().generateMnemonic(strength: 128, passphrase: call.arguments as! String) let (isValid, err) = WalletHandler.validate(walletError: WalletError(code: .noWallet, message: "Could not generate wallet", details: nil), wallet) if isValid { - result(wallet) + result(wallet) }else { result(err.details) } @@ -77,7 +77,7 @@ public class SwiftTrustdartPlugin: NSObject, FlutterPlugin { result(txHash) }else { result(err.details) - } + } }else { result(err.details) } @@ -85,13 +85,12 @@ public class SwiftTrustdartPlugin: NSObject, FlutterPlugin { case "multiSignTransaction": let args = call.arguments as! [String: Any] let coin: String? = args["coin"] as? String - let path: String? = args["path"] as? String let txData: [String: Any]? = args["txData"] as? [String: Any] let privateKeys: [String]? = args["privateKeys"] as? [String] - let (isValid, err) = WalletHandler.validate(walletError: WalletError(code: .argumentsNull, message: "[coin] and [path] are required.", details: nil), coin, path) + let (isValid, err) = WalletHandler.validate(walletError: WalletError(code: .argumentsNull, message: "[coin] are required.", details: nil), coin) if isValid { - let txHash = WalletHandler().getCoin(coin!).multiSignTransaction(path: path!, txData: txData!, privateKeys: privateKeys ?? [] ) + let txHash = WalletHandler().getCoin(coin!).multiSignTransaction(txData: txData!, privateKeys: privateKeys ?? [] ) let (isValid, err) = WalletHandler.validate(walletError: WalletError(code: .txHashNull, message: "Failed to sign transaction.", details: nil), txHash) if isValid { diff --git a/ios/Classes/coins/BTC.swift b/ios/Classes/coins/BTC.swift index 916e78c..86a0aa1 100644 --- a/ios/Classes/coins/BTC.swift +++ b/ios/Classes/coins/BTC.swift @@ -48,7 +48,7 @@ class BTC: Coin { $0.privateKey = [privateKey!.data] $0.plan = BitcoinTransactionPlan.with { $0.amount = txData["amount"] as! Int64 - $0.fee = txData["fees"] as! Int64 + $0.fee = txData["fees"] as! Int64 $0.change = txData["change"] as! Int64 $0.utxos = unspent } @@ -64,7 +64,7 @@ class BTC: Coin { - override func multiSignTransaction(path: String, txData: [String : Any], privateKeys: [String]) -> String? { + override func multiSignTransaction(txData: [String : Any], privateKeys: [String]) -> String? { let utxos: [[String: Any]] = txData["utxos"] as! [[String: Any]] var unspent: [BitcoinUnspentTransaction] = [] diff --git a/ios/Classes/protocols/CoinProtocol.swift b/ios/Classes/protocols/CoinProtocol.swift index 0367028..9f08df2 100644 --- a/ios/Classes/protocols/CoinProtocol.swift +++ b/ios/Classes/protocols/CoinProtocol.swift @@ -18,6 +18,6 @@ protocol CoinProtocol { func validateAddress(address: String) -> Bool func signDataWithPrivateKey(path: String, mnemonic: String, passphrase: String, txData: String) -> String? func signTransaction(path: String, txData: [String: Any], mnemonic: String, passphrase: String) -> String? - func multiSignTransaction(path: String, txData: [String: Any], privateKeys: [String]) -> String? + func multiSignTransaction(txData: [String: Any], privateKeys: [String]) -> String? } diff --git a/lib/trustdart.dart b/lib/trustdart.dart index b366471..020bc6d 100644 --- a/lib/trustdart.dart +++ b/lib/trustdart.dart @@ -171,15 +171,13 @@ class Trustdart { } } - static Future multiSignTransaction(String mnemonic, String coin, - String path, Map txData, List? privateKeys, - [String passphrase = ""]) async { + static Future multiSignTransaction(String coin, + String path, Map txData, List? privateKeys) async { try { final String txHash = await _channel.invokeMethod( 'multiSignTransaction', { 'coin': coin, 'txData': txData, - 'path': path, 'privateKeys': privateKeys }); return txHash;