MCPcopy Create free account
hub / github.com/chain/Core / Build

Method Build

core/account/builder.go:187–207  ·  view source on GitHub ↗
(ctx context.Context, b *txbuilder.TemplateBuilder)

Source from the content-addressed store, hash-verified

185}
186
187func (a *controlAction) Build(ctx context.Context, b *txbuilder.TemplateBuilder) error {
188 var missing []string
189 if a.AccountID == "" {
190 missing = append(missing, "account_id")
191 }
192 if a.AssetId.IsZero() {
193 missing = append(missing, "asset_id")
194 }
195 if len(missing) > 0 {
196 return txbuilder.MissingFieldsError(missing...)
197 }
198
199 // Produce a control program, but don't insert it into the database yet.
200 acp, err := a.accounts.createControlProgram(ctx, a.AccountID, false, b.MaxTime())
201 if err != nil {
202 return err
203 }
204 a.accounts.insertControlProgramDelayed(ctx, b, acp)
205
206 return b.AddOutput(legacy.NewTxOutput(*a.AssetId, a.Amount, acp.controlProgram, a.ReferenceData))
207}
208
209// insertControlProgramDelayed takes a template builder and an account
210// control program that hasn't been inserted to the database yet. It

Callers

nothing calls this directly

Calls 5

MaxTimeMethod · 0.80
AddOutputMethod · 0.80
IsZeroMethod · 0.45
createControlProgramMethod · 0.45

Tested by

no test coverage detected