private OfferScriptPubKeyParameters CreateOfferScriptParameters() { return(new OfferScriptPubKeyParameters { Hashes = _PuzzleElements.OfType <RealPuzzle>().Select(p => p.Commitment.KeyHash).ToArray(), FulfillKey = InternalState.FulfillKey, RedeemKey = InternalState.RedeemKey.PubKey, Expiration = EscrowScriptBuilder.ExtractEscrowScriptPubKeyParameters(InternalState.EscrowedCoin.Redeem).LockTime }); }
private PubKey[] GetExpectedSigners() { var parameters = EscrowScriptBuilder.ExtractEscrowScriptPubKeyParameters(InternalState.EscrowedCoin.GetScriptCode()); if (parameters == null) { throw new ArgumentException("Invalid escrow"); } return(parameters.EscrowKeys); }
private Script CreateEscrowScript() { return(EscrowScriptBuilder.CreateEscrow( new[] { InternalState.EscrowKey.PubKey, InternalState.OtherEscrowKey }, InternalState.RedeemKey.PubKey, GetCycle().GetTumblerLockTime())); }
private Script GetOfferScript() { var escrow = EscrowScriptBuilder.ExtractEscrowScriptPubKeyParameters(InternalState.EscrowedCoin.Redeem); return(SolverScriptBuilder.CreateOfferScript(new OfferScriptPubKeyParameters { Hashes = InternalState.SolvedPuzzles.Select(p => p.SolutionKey.GetHash()).ToArray(), FulfillKey = InternalState.FulfillKey.PubKey, RedeemKey = escrow.RedeemKey, Expiration = escrow.LockTime })); }
private ScriptCoin CreateEscrowCoin(PubKey escrow1, PubKey escrow2, PubKey redeemKey) { var redeem = EscrowScriptBuilder.CreateEscrow(new[] { escrow1, escrow2 }, redeemKey, new LockTime(0)); var scriptCoin = new Coin(new OutPoint(new uint256(RandomUtils.GetBytes(32)), 0), new TxOut { Value = Money.Coins(1.5m), ScriptPubKey = redeem.Hash.ScriptPubKey }).ToScriptCoin(redeem); return(scriptCoin); }
public PromiseClientSession ReceiveTumblerEscrowedCoin(ScriptCoin escrowedCoin) { AssertState(TumblerClientSessionStates.WaitingTumblerEscrow); var escrow = EscrowScriptBuilder.ExtractEscrowScriptPubKeyParameters(escrowedCoin.Redeem); if (escrow == null || !escrow.EscrowKeys.Contains(InternalState.TumblerEscrowKey.PubKey)) { throw new PuzzleException("invalid-escrow"); } if (escrowedCoin.Amount != Parameters.Denomination) { throw new PuzzleException("invalid-amount"); } InternalState.Status = TumblerClientSessionStates.PromisePhase; var session = new PromiseClientSession(Parameters.CreatePromiseParamaters()); session.ConfigureEscrowedCoin(escrowedCoin, InternalState.TumblerEscrowKey); InternalState.TumblerEscrowKey = null; return(session); }
public Script CreateEscrow(LockTime lockTime) { return(EscrowScriptBuilder.CreateEscrow(new PubKey[] { OurEscrowKey, OtherEscrowKey }, RedeemKey, lockTime)); }
public PubKey GetClientEscrowPubKey() { return(EscrowScriptBuilder.ExtractEscrowScriptPubKeyParameters(EscrowedCoin.Redeem) .EscrowKeys .First(e => e != EscrowKey.PubKey)); }