// automatically generated by the FlatBuffers compiler, do not modify

import * as flatbuffers from 'flatbuffers';

export class WalletSegment {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):WalletSegment {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsWalletSegment(bb:flatbuffers.ByteBuffer, obj?:WalletSegment):WalletSegment {
  return (obj || new WalletSegment()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsWalletSegment(bb:flatbuffers.ByteBuffer, obj?:WalletSegment):WalletSegment {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new WalletSegment()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

source():string|null
source(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
source(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

chips():number {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}

spendable():boolean {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
}

static startWalletSegment(builder:flatbuffers.Builder) {
  builder.startObject(3);
}

static addSource(builder:flatbuffers.Builder, sourceOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, sourceOffset, 0);
}

static addChips(builder:flatbuffers.Builder, chips:number) {
  builder.addFieldInt32(1, chips, 0);
}

static addSpendable(builder:flatbuffers.Builder, spendable:boolean) {
  builder.addFieldInt8(2, +spendable, +false);
}

static endWalletSegment(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

static createWalletSegment(builder:flatbuffers.Builder, sourceOffset:flatbuffers.Offset, chips:number, spendable:boolean):flatbuffers.Offset {
  WalletSegment.startWalletSegment(builder);
  WalletSegment.addSource(builder, sourceOffset);
  WalletSegment.addChips(builder, chips);
  WalletSegment.addSpendable(builder, spendable);
  return WalletSegment.endWalletSegment(builder);
}
}
