Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction {
    pub signature: Signature,
    pub signer_public_key: PublicKey,
    pub network: NetworkIdentifier,
    pub fee: u64,
    pub deadline: u64,
    pub body: Body,
    /* private fields */
}
Expand description

トランザクション。catbuffer の Transaction に、種類ごとの本体が続く。

Fields§

§signature: Signature

署名者の署名。署名する前は、catapult の SDK と同じく0で埋めておく。

§signer_public_key: PublicKey§network: NetworkIdentifier§fee: u64

手数料。通貨のモザイクの最小単位で数える。

§deadline: u64

期限。ネットワークのエポックからのミリ秒。

§body: Body

Implementations§

Source§

impl Transaction

Source

pub fn validate(&self, parameters: &NetworkParameters) -> Vec<Problem>

ノードが状態を見ずに弾くところがないか確かめる。ノードが確かめる順に並べて返し、なければ空。

ノードは最初の1つで止めるので、REST のステータスに出るのは先頭のもの。ただし Failure::TopLevelNotSupported なら、 ステータスには何も出ない。

Source§

impl Transaction

Source

pub fn new( signer_public_key: PublicKey, network: NetworkIdentifier, fee: u64, deadline: u64, body: Body, ) -> Self

署名していないトランザクションを作る。署名は0で埋める。

Source

pub fn size(&self) -> usize

バイト数。アグリゲートなら、今付いている連署も数える。

Source

pub fn fee_for(&self, fee_multiplier: u32, cosignature_count: usize) -> u64

手数料の倍率 fee_multiplier で、ブロックに入れてもらうのに要る手数料。 catapult の CalculateTransactionFee と同じく、バイト数に倍率を掛けたもの。

アグリゲートにこれから連署が付くなら、その数を cosignature_count に渡す。連署1つで104バイト増え、 ノードは連署の付いたあとのバイト数で手数料を確かめる。公式の SDK の calculate_transaction_fee と同じ。

Source

pub fn max_fee_multiplier(&self) -> u32

手数料から、ブロックに入れてもらえる倍率の上限を求める。catapult の CalculateTransactionMaxFeeMultiplier。 ハーベストする人は、ブロックの倍率がこれ以下のときだけ、このトランザクションを入れられる。

Source

pub fn to_bytes(&self) -> Vec<u8> ⓘ

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, DecodeError>

バイト列から読む。書き戻したときに同じバイト列にならないものは弾く。 catapult が確かめない予約の部分は、0 でなくても読み、その値のまま書き戻す。

Source

pub fn sign( &mut self, private_key: &PrivateKey, generation_hash_seed: &GenerationHashSeed, ) -> Result<(), SignError>

署名する。署名者の公開鍵は署名の対象に含まれるので、秘密鍵と合っていなければ弾く。

Source

pub fn signing_payload( &self, generation_hash_seed: &GenerationHashSeed, ) -> Vec<u8> ⓘ

署名するバイト列。generation hash seed に、署名の対象の部分を続けたもの。公式の SDK の extract_signing_payload。 秘密鍵を別の場所(ハードウェアや別のプロセス)に置いて署名するときは、これを Ed25519 で署名して Transaction::attach_signature で付ける。

Source

pub fn attach_signature( &mut self, signature: Signature, generation_hash_seed: &GenerationHashSeed, ) -> Result<(), SignError>

別の場所で作った署名を付ける。公式の SDK の attach_signature と違い、署名者の公開鍵で 検証できない署名は付けない。

Source

pub fn verify(&self, generation_hash_seed: &GenerationHashSeed) -> bool

署名を検証する。catapult の SignatureValidator と同じく、 generation hash seed に続けて、署名の対象の部分に署名されていることを確かめる。

Source

pub fn hash(&self, generation_hash_seed: &GenerationHashSeed) -> Hash256

ハッシュ。catapult の model/EntityHasher.cpp と同じく、署名を丸ごとと署名者の公開鍵、 generation hash seed、署名の対象の部分を続けた SHA3-256。

Source

pub fn merkle_component_hash( &self, generation_hash_seed: &GenerationHashSeed, ) -> Hash256

ブロックの TransactionsHash の葉。catapult の CalculateMerkleComponentHash。

ふつうはハッシュそのもの。アグリゲートは、ハッシュに連署者の公開鍵を並んだ順に続けた SHA3-256 (aggregate プラグインの merkleSupplementaryBuffers)。連署はハッシュに入らないので、 ブロックはこちらで連署の取り違えを防ぐ。

Nemesis のブロックだけは、ヘッダーの TransactionsHash をこの値ではなく、トランザクションを丸ごとハッシュした葉で作っている。 Nemesis では heika-block の Block::merkle_leaves を使う。

Source

pub fn cosign( &mut self, private_key: &PrivateKey, generation_hash_seed: &GenerationHashSeed, ) -> Result<(), CosignError>

アグリゲートに private_key の連署を足す。

連署するのは外側の署名を含むハッシュなので、先に署名されていなければならない。 catapult の BasicAggregateCosignaturesValidator と同じく、外側の署名者やすでに連署した鍵の連署は弾く。 誰の連署が要るかはマルチシグの設定で決まるので、ここでは確かめない。

Source

pub fn attach_cosignature( &mut self, detached: &DetachedCosignature, generation_hash_seed: &GenerationHashSeed, ) -> Result<(), CosignError>

切り離して集めた連署を、アグリゲートに付ける。Transaction::cosign と同じものを弾くほか、 連署したアグリゲートがこれでないものと、署名が正しくないものも弾く。

Source

pub fn take_cosignatures(&mut self) -> Vec<Cosignature>

連署を外して返す。アグリゲートでなければ空

Source

pub fn verify_cosignatures( &self, generation_hash_seed: &GenerationHashSeed, ) -> bool

連署をすべて検証する。アグリゲートでなければ連署はないので true。

Trait Implementations§

Source§

impl Clone for Transaction

Source§

fn clone(&self) -> Transaction

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transaction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Transaction

Source§

impl PartialEq for Transaction

Source§

fn eq(&self, other: &Transaction) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Transaction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.