diff --git a/RpcWallet/RpcWallet.cs b/RpcWallet/RpcWallet.cs index 6c33f92b1..ff9e91cb8 100644 --- a/RpcWallet/RpcWallet.cs +++ b/RpcWallet/RpcWallet.cs @@ -1,4 +1,4 @@ -using Akka.Actor; +using Akka.Actor; using Microsoft.AspNetCore.Http; using Neo.IO; using Neo.IO.Json; @@ -307,6 +307,19 @@ private JObject SendFrom(UIntBase assetId, UInt160 from, UInt160 to, string valu ScriptHash = to } }, from: from, change_address: change_address, fee: fee); + if (tx.Size > 1024) + { + fee += Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m); + tx = Wallet.MakeTransaction(null, new[] + { + new TransferOutput + { + AssetId = assetId, + Value = amount, + ScriptHash = to + } + }, from: from, change_address: change_address, fee: fee); + } if (tx == null) throw new RpcException(-300, "Insufficient funds"); return SignAndRelay(tx); @@ -334,6 +347,11 @@ private JObject SendMany(UInt160 from, JArray to, Fixed8 fee, UInt160 change_add if (fee < Fixed8.Zero) throw new RpcException(-32602, "Invalid params"); Transaction tx = Wallet.MakeTransaction(null, outputs, from: from, change_address: change_address, fee: fee); + if (tx.Size > 1024) + { + fee += Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m); + tx = Wallet.MakeTransaction(null, outputs, from: from, change_address: change_address, fee: fee); + } if (tx == null) throw new RpcException(-300, "Insufficient funds"); return SignAndRelay(tx); @@ -357,6 +375,19 @@ private JObject SendToAddress(UIntBase assetId, UInt160 scriptHash, string value ScriptHash = scriptHash } }, change_address: change_address, fee: fee); + if (tx.Size > 1024) + { + fee += Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m); + tx = Wallet.MakeTransaction(null, new[] + { + new TransferOutput + { + AssetId = assetId, + Value = amount, + ScriptHash = scriptHash + } + }, change_address: change_address, fee: fee); + } if (tx == null) throw new RpcException(-300, "Insufficient funds"); return SignAndRelay(tx);