pub struct Bob<Addr, Ar, Ac> {
    pub arbitrating: Ar,
    pub accordant: Ac,
    pub refund_address: Addr,
    pub fee_politic: FeePriority,
}
Expand description

Bob, a SwapRole, starts with arbitrating blockchain assets and exchange them for accordant blockchain assets.

Fields§

§arbitrating: Ar

The arbitrating blockchain to use during the swap

§accordant: Ac

The accordant blockchain to use during the swap

§refund_address: Addr

An arbitrating address where, if unsuccessfully executed, the funds exchanged will be sent back to

§fee_politic: FeePriority

The fee politic to apply during the swap fee calculation

Implementations§

Create a new Bob role with the local parameters.

Generate Bob’s parameters for the protocol execution based on a key generator.

Safety

All the data passed to the function are considered trusted and does not require extra validation. The deal is assumend to be validated by user upfront.

Initialize the core arbitrating transactions composed of: Lockable, Cancelable, and Refundable transactions.

Safety

Alice’s Parameters (i.e. counter-party parameters) are created and validated with the protocol messages that commit and reveal the values.

This function assumes that the commit/reveal scheme has been validated and assumes that all cryptographic proof needed for securing the system have passed the validation.

Previously verified data:

  • alice_parameters: Alice’s parameters
  • arb_params: The core arbitrating parameter used in verification

Trusted data:

  • bob_parameters: Bob’s own parameters
  • funding: Bob’s own funding transaction
Execution

The parameters to create the three transactions are:

The lock transaction is initialized by passing the DataLock structure, then the cancel transaction is initialized based on the lock transaction with the DataPunishableLock structure, then the punish is initialized based on the cancel transaction.

Transaction Fee

The fee on each transactions are set according to the FeeStrategy specified in the deal and the FeePriority in self.

Co-sign the arbitrating Cancelable transaction.

Safety

All the data passed to cosign_arbitrating_cancel are considered trusted.

The signature is created by Bob and does not require any extra validation.

Execution

Returns the signature.

Validates the adaptor refund witness based on the parameters and the core arbitrating transactions.

Safety

Alice’s Parameters (i.e. counter-party parameters) are created and validated with the protocol messages that commit and reveal the values.

This function assumes that the commit/reveal scheme has been validated and assumes that all cryptographic proof needed for securing the system have passed the validation.

CoreArbitratingTransactions protocol message is created by Bob and does not require any extra validation.

Previously verified data:

  • alice_parameters: Alice’s parameters

Trusted data:

  • bob_parameters: Bob’s own parameters
  • core: Core arbitrating transactions

Verified data:

  • refund_adaptor_sig: The adaptor witness to verify
Execution

Return Ok(()) if all tests succeed.

Creates the Buyable transaction and generate the adaptor witness

Safety

This function MUST NOT be run if validate_adaptor_refund is not successful.

This function MUST NOT be run if the accordant assets are not confirmed on-chain.

Alice’s Parameters (i.e. counter-party parameters) are created and validated with the protocol messages that commit and reveal the values.

This function assumes that the commit/reveal scheme has been validated and assumes that all cryptographic proof needed for securing the system have passed the validation.

CoreArbitratingTransactions protocol message is created by Bob and does not require any extra validation.

Previously verified data:

  • alice_parameters: Alice’s parameters
  • arb_params: The parameters used to verify core

Trusted data:

  • wallet: Bob’s own wallet, used to perform cryptographic operations
  • bob_parameters: Bob’s own parameters
  • core: Core arbitrating transactions
Execution
  • Parse the Lockable partial transaction in CoreArbitratingTransactions
  • Generate the DataLock structure from Alice and Bob parameters and the deal
  • Retrieve Alice’s adaptor public key from Alice’s Parameters
  • Retreive the buy public key from the paramters
  • Generate the adaptor witness data and sign it

Returns the partial transaction and the signature inside the BuyProcedureSignature protocol message.

Sign the arbitrating Lockable transaction and return the signature.

Safety

This function MUST NOT be run if validate_adaptor_refund is not successful.

All the data passed to sign_arbitrating_lock are considered trusted.

CoreArbitratingTransactions protocol message is created by Bob and does not require any extra validation.

Execution

Returns the signature.

Sign the arbitrating Refundable transaction and adapt the counter-party adaptor witness with the private adaptor key.

Safety

This function MUST NOT be run if validate_adaptor_refund is not successful.

The encrypted signature is created by Alice and must be verified to be a valid.

This function assumes that the adaptor signature has been validated and assumes that all cryptographic proof needed for securing the system have passed the validation.

CoreArbitratingTransactions protocol message is created by Bob and does not require any extra validation.

Execution
  • Parse the Refundable partial transaction in CoreArbitratingTransactions
  • Retreive the refund public key from the paramters
  • Generate the refund witness data
  • Retreive the adaptor public key from the pamaters
  • Adapt the signature

Returns the signatures inside a TxSignatures structure.

This function allows to recover the secret key used to encrypt the buy signature, allowing Bob to recover Alice’s secret and transfer ownership of funds.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Decode an object with a well-defined format
Encode an object with a well-defined format, should only ever error if the underlying encoder errors. If successful, returns size of the encoded object in bytes. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Causes self to use its Binary implementation when Debug-formatted.
Causes self to use its Display implementation when Debug-formatted.
Causes self to use its LowerExp implementation when Debug-formatted.
Causes self to use its LowerHex implementation when Debug-formatted.
Causes self to use its Octal implementation when Debug-formatted.
Causes self to use its Pointer implementation when Debug-formatted.
Causes self to use its UpperExp implementation when Debug-formatted.
Causes self to use its UpperHex implementation when Debug-formatted.
Formats each item in a sequence. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Returns a new instance of the invocant that will be marked with M. Read more
Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function.
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function.
Should always be Self
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds.
Calls .tap_borrow() only in debug builds, and is erased in release builds.
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Calls .tap_ref() only in debug builds, and is erased in release builds.
Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Calls .tap_deref() only in debug builds, and is erased in release builds.
Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.