Esempio n. 1
0
 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
     });
 }
Esempio n. 2
0
        private PubKey[] GetExpectedSigners()
        {
            var parameters = EscrowScriptBuilder.ExtractEscrowScriptPubKeyParameters(InternalState.EscrowedCoin.GetScriptCode());

            if (parameters == null)
            {
                throw new ArgumentException("Invalid escrow");
            }
            return(parameters.EscrowKeys);
        }
        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
            }));
        }
        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 PubKey GetClientEscrowPubKey()
 {
     return(EscrowScriptBuilder.ExtractEscrowScriptPubKeyParameters(EscrowedCoin.Redeem)
            .EscrowKeys
            .First(e => e != EscrowKey.PubKey));
 }