Verify and combine signatures
MODIFY
HiddenWallet.ChaumianTumbler/Controllers/TumblerController.cs
HiddenWallet.ChaumianTumbler/Controllers/TumblerController.cs
@@ -315,7 +315,7 @@ namespace HiddenWallet.ChaumianTumbler.Controllers
return new ObjectResult(new CoinJoinResponse
{
- Transaction = Global.StateMachine.UnsignedCoinJoin.ToHex()
+ Transaction = Global.StateMachine.CoinJoin.ToHex()
});
}
catch (Exception ex)
@@ -343,30 +343,40 @@ namespace HiddenWallet.ChaumianTumbler.Controllers
using (await SignatureProvidedAsyncLock.LockAsync())
{
- if (Global.StateMachine.CoinJoinToSign == null)
+ foreach (var signatureModel in request.Signatures)
{
- foreach(var input in Global.StateMachine.UnsignedCoinJoin.Inputs)
+ var witness = new WitScript(signatureModel.Witness);
+ if(Global.StateMachine.CoinJoin.Inputs.Count <= signatureModel.Index)
{
- Global.StateMachine.CoinJoinToSign.AddInput(input);
+ // round fails, ban alice
+ throw new NotImplementedException();
}
- foreach (var output in Global.StateMachine.UnsignedCoinJoin.Outputs)
+ if(Global.StateMachine.CoinJoin.Inputs[signatureModel.Index].WitScript != default)
{
- Global.StateMachine.CoinJoinToSign.AddOutput(output);
- }
+ // round fails, ban alice
+ throw new NotImplementedException();
}
-
- foreach (var signatureModel in request.Signatures)
+ Global.StateMachine.CoinJoin.Inputs[signatureModel.Index].WitScript = witness;
+ var output = alice.Inputs.Single(x => x.OutPoint == Global.StateMachine.CoinJoin.Inputs[signatureModel.Index].PrevOut).Output;
+ if(!Script.VerifyScript(output.ScriptPubKey, Global.StateMachine.CoinJoin, signatureModel.Index, output.Value, ScriptVerify.Standard, SigHash.All))
{
- var signature = HexHelpers.GetBytes(signatureModel.Witness);
-
- // todo find input
- // add signature
- // check if correctly signed
+ // round fails, ban alice
+ throw new NotImplementedException();
}
}
+ // check if fully signed
+ if(Global.StateMachine.CoinJoin.Inputs.All(x => x.WitScript != default))
+ {
+ // propagate transaction
+ // save coinjoin to coinjoinstore
+ // progress round
throw new NotImplementedException();
}
+
+ return new ObjectResult(new SuccessResponse());
+ }
+ }
catch (Exception ex)
{
return new ObjectResult(new FailureResponse { Message = ex.Message, Details = ex.ToString() });

MODIFY
HiddenWallet.ChaumianTumbler/TumblerStateMachine.cs
HiddenWallet.ChaumianTumbler/TumblerStateMachine.cs
@@ -28,8 +28,7 @@ namespace HiddenWallet.ChaumianTumbler
public Stopwatch InputRegistrationStopwatch { get; private set; }
public bool FallBackRound { get; private set; } = false;
- public Transaction UnsignedCoinJoin { get; private set; } = null;
- public Transaction CoinJoinToSign { get; set; } = null;
+ public Transaction CoinJoin { get; private set; } = null;
private SmartBitClient SmartBitClient { get; } = new SmartBitClient(Network.Main);
public ConcurrentHashSet<Alice> Alices { get; private set; }
@@ -139,7 +138,7 @@ namespace HiddenWallet.ChaumianTumbler
}
FallBackRound = false;
UpdatePhase(TumblerPhase.InputRegistration);
- UnsignedCoinJoin = null;
+ CoinJoin = null;
break;
}
default:
@@ -172,7 +171,7 @@ namespace HiddenWallet.ChaumianTumbler
}
var builder = new TransactionBuilder();
- UnsignedCoinJoin = builder
+ CoinJoin = builder
.ContinueToBuild(transaction)
.Shuffle()
.BuildTransaction(false);

Verify and combine signatures