nus-yam/ex-repair huggingface dataset:
Program: 35040
Project: 35040
Buggy source:
@PUT @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str",response=Result.class)}) public Result updatePasswordByPriKey(@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) @PathParam("String_Node_Str") String address,@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) AccountPriKeyPasswordForm form){
  if (!Address.validAddress(address)) {
    return Result.getFailed(AccountErrorCode.ADDRESS_ERROR);
  }
  String prikey=form.getPriKey();
  if (!ECKey.isValidPrivteHex(prikey)) {
    return Result.getFailed(AccountErrorCode.PARAMETER_ERROR,"String_Node_Str");
  }
  String newPassword=form.getPassword();
  if (StringUtils.isBlank(newPassword)) {
    return Result.getFailed(AccountErrorCode.PARAMETER_ERROR,"String_Node_Str");
  }
  if (!StringUtils.validPassword(newPassword)) {
    return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG,"String_Node_Str");
  }
  return this.accountBaseService.changePasswordByPrikey(address,prikey,newPassword);
}

Fixed version (ground truth):
@PUT @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str",response=Result.class)}) public Result updatePasswordByPriKey(@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) AccountPriKeyChangePasswordForm form){
  String prikey=form.getPriKey();
  if (!ECKey.isValidPrivteHex(prikey)) {
    return Result.getFailed(AccountErrorCode.PARAMETER_ERROR,"String_Node_Str");
  }
  String newPassword=form.getPassword();
  if (StringUtils.isBlank(newPassword)) {
    return Result.getFailed(AccountErrorCode.PARAMETER_ERROR,"String_Node_Str");
  }
  if (!StringUtils.validPassword(newPassword)) {
    return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG,"String_Node_Str");
  }
  Result result=accountService.importAccount(prikey,newPassword);
  if (result.isFailed()) {
    return result;
  }
  Account account=(Account)result.getData();
  return Result.getSuccess().setData(account.getAddress().toString());
}
Program: 35043
Project: 35043
Buggy source:
/** 
 * 保存别名 1.保存别名alias至数据库 2.从数据库取出对应的account账户,将别名设置进account然后保存至数据库 3.将修改后的account重新进行缓存 saveAlias 1. Save the alias to the database. 2. Take the corresponding account from the database, set the alias to account and save it to the database. 3. Re-cache the modified account.
 * @param aliaspo
 * @return
 */
public Result saveAlias(AliasPo aliaspo) throws NulsException {
  try {
    Result result=aliasStorageService.saveAlias(aliaspo);
    if (result.isFailed()) {
      this.rollbackAlias(aliaspo);
    }
    AccountPo po=accountStorageService.getAccount(aliaspo.getAddress()).getData();
    if (null == po) {
      return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
    }
    po.setAlias(aliaspo.getAlias());
    Result resultAcc=accountStorageService.updateAccount(po);
    if (resultAcc.isFailed()) {
      this.rollbackAlias(aliaspo);
    }
  }
 catch (  Exception e) {
    this.rollbackAlias(aliaspo);
    Log.error(e);
    return Result.getFailed(AccountErrorCode.FAILED);
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
/** 
 * 保存别名(全网) 1.保存别名alias至数据库 2.从数据库取出对应的account账户,将别名设置进account然后保存至数据库 3.将修改后的account重新进行缓存 saveAlias 1. Save the alias to the database. 2. Take the corresponding account from the database, set the alias to account and save it to the database. 3. Re-cache the modified account.
 * @param aliaspo
 * @return
 */
public Result saveAlias(AliasPo aliaspo) throws NulsException {
  try {
    Result result=aliasStorageService.saveAlias(aliaspo);
    if (result.isFailed()) {
      this.rollbackAlias(aliaspo);
    }
    AccountPo po=accountStorageService.getAccount(aliaspo.getAddress()).getData();
    if (null != po) {
      po.setAlias(aliaspo.getAlias());
      Result resultAcc=accountStorageService.updateAccount(po);
      if (resultAcc.isFailed()) {
        this.rollbackAlias(aliaspo);
      }
    }
  }
 catch (  Exception e) {
    this.rollbackAlias(aliaspo);
    Log.error(e);
    return Result.getFailed(AccountErrorCode.FAILED);
  }
  return Result.getSuccess();
}
Program: 35044
Project: 35044
Buggy source:
/** 
 * 回滚别名操作(删除别名) 1.从数据库删除别名对象数据 2.取出对应的account将别名清除,重新存入数据库 3.重新缓存account rollbackAlias 1.Delete the alias data from the database. 2. Remove the corresponding account to clear the alias and restore it in the database. 3. Recache the account.
 * @param aliasPo
 * @return
 */
public Result rollbackAlias(AliasPo aliasPo) throws NulsException {
  try {
    AliasPo po=aliasStorageService.getAlias(aliasPo.getAlias()).getData();
    if (po != null && Base58.encode(po.getAddress()).equals(Base58.encode(aliasPo.getAddress()))) {
      aliasStorageService.removeAlias(aliasPo.getAlias());
      AccountPo accountPo=accountStorageService.getAccount(aliasPo.getAddress()).getData();
      accountPo.setAlias("String_Node_Str");
      accountStorageService.updateAccount(accountPo);
    }
  }
 catch (  Exception e) {
    Log.error(e);
    throw new NulsException(AccountErrorCode.ALIAS_ROLLBACK_ERROR);
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
/** 
 * 回滚别名操作(删除别名(全网)) 1.从数据库删除别名对象数据 2.取出对应的account将别名清除,重新存入数据库 3.重新缓存account rollbackAlias 1.Delete the alias data from the database. 2. Remove the corresponding account to clear the alias and restore it in the database. 3. Recache the account.
 * @param aliasPo
 * @return
 */
public Result rollbackAlias(AliasPo aliasPo) throws NulsException {
  try {
    AliasPo po=aliasStorageService.getAlias(aliasPo.getAlias()).getData();
    if (po != null && Base58.encode(po.getAddress()).equals(Base58.encode(aliasPo.getAddress()))) {
      aliasStorageService.removeAlias(aliasPo.getAlias());
      Result<AccountPo> rs=accountStorageService.getAccount(aliasPo.getAddress());
      if (rs.isSuccess()) {
        AccountPo accountPo=rs.getData();
        accountPo.setAlias("String_Node_Str");
        accountStorageService.updateAccount(accountPo);
      }
    }
  }
 catch (  Exception e) {
    Log.error(e);
    throw new NulsException(AccountErrorCode.ALIAS_ROLLBACK_ERROR);
  }
  return Result.getSuccess();
}
Program: 35045
Project: 35045
Buggy source:
@BeforeClass public static void beforeClass(){
  MicroKernelBootstrap kernel=MicroKernelBootstrap.getInstance();
  kernel.init();
  kernel.start();
  aliasService=SpringLiteContext.getBean(AliasService.class);
  accountService=SpringLiteContext.getBean(AccountService.class);
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass(){
  MicroKernelBootstrap kernel=MicroKernelBootstrap.getInstance();
  kernel.init();
  kernel.start();
  LevelDbModuleBootstrap db=new LevelDbModuleBootstrap();
  db.init();
  db.start();
  aliasService=SpringLiteContext.getBean(AliasService.class);
  accountBaseService=SpringLiteContext.getBean(AccountBaseService.class);
  accountService=SpringLiteContext.getBean(AccountService.class);
}
Program: 35046
Project: 35046
Buggy source:
@Override public Result<AccountPo> getAccount(byte[] address){
  AccountPo account=dbService.getModel(AccountStorageConstant.DB_NAME_ACCOUNT,address,AccountPo.class);
  return Result.getSuccess().setData(account);
}

Fixed version (ground truth):
@Override public Result<AccountPo> getAccount(byte[] address){
  AccountPo account=dbService.getModel(AccountStorageConstant.DB_NAME_ACCOUNT,address,AccountPo.class);
  if (null == account) {
    return Result.getFailed();
  }
  return Result.getSuccess().setData(account);
}
Program: 35048
Project: 35048
Buggy source:
@Override public Result onCommit(AliasTransaction tx,Object secondaryData){
  Alias alias=tx.getTxData();
  return aliasService.saveAlias(new AliasPo(alias));
}

Fixed version (ground truth):
@Override public Result onCommit(AliasTransaction tx,Object secondaryData){
  Alias alias=tx.getTxData();
  try {
    return aliasService.saveAlias(new AliasPo(alias));
  }
 catch (  NulsException e) {
    Log.error(e);
    return Result.getFailed(AccountErrorCode.FAILED);
  }
}
Program: 35049
Project: 35049
Buggy source:
@Override public Result onRollback(AliasTransaction tx,Object secondaryData){
  Alias alias=tx.getTxData();
  return aliasService.rollbackAlias(new AliasPo(alias));
}

Fixed version (ground truth):
@Override public Result onRollback(AliasTransaction tx,Object secondaryData){
  Alias alias=tx.getTxData();
  try {
    return aliasService.rollbackAlias(new AliasPo(alias));
  }
 catch (  NulsException e) {
    Log.error(e);
    return Result.getFailed(AccountErrorCode.ALIAS_ROLLBACK_ERROR);
  }
}
Program: 35051
Project: 35051
Buggy source:
/** 
 * 保存别名 1.保存别名alias至数据库 2.从数据库取出对应的account账户,将别名设置进account然后保存至数据库 3.将修改后的account重新进行缓存 saveAlias 1. Save the alias to the database. 2. Take the corresponding account from the database, set the alias to account and save it to the database. 3. Re-cache the modified account.
 * @param aliaspo
 * @return
 */
public Result saveAlias(AliasPo aliaspo){
  try {
    aliasStorageService.saveAlias(aliaspo);
    AccountPo po=accountStorageService.getAccount(aliaspo.getAddress()).getData();
    if (null == po) {
      return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
    }
    po.setAlias(aliaspo.getAlias());
    accountStorageService.updateAccount(po);
    accountCacheService.putAccount(po.toAccount());
  }
 catch (  Exception e) {
    throw new NulsRuntimeException(AccountErrorCode.FAILED);
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
/** 
 * 保存别名 1.保存别名alias至数据库 2.从数据库取出对应的account账户,将别名设置进account然后保存至数据库 3.将修改后的account重新进行缓存 saveAlias 1. Save the alias to the database. 2. Take the corresponding account from the database, set the alias to account and save it to the database. 3. Re-cache the modified account.
 * @param aliaspo
 * @return
 */
public Result saveAlias(AliasPo aliaspo) throws NulsException {
  try {
    Result result=aliasStorageService.saveAlias(aliaspo);
    if (result.isFailed()) {
      this.rollbackAlias(aliaspo);
    }
    AccountPo po=accountStorageService.getAccount(aliaspo.getAddress()).getData();
    if (null == po) {
      return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
    }
    po.setAlias(aliaspo.getAlias());
    Result resultAcc=accountStorageService.updateAccount(po);
    if (resultAcc.isFailed()) {
      this.rollbackAlias(aliaspo);
    }
  }
 catch (  Exception e) {
    this.rollbackAlias(aliaspo);
    Log.error(e);
    return Result.getFailed(AccountErrorCode.FAILED);
  }
  return Result.getSuccess();
}
Program: 35052
Project: 35052
Buggy source:
/** 
 * 回滚别名操作(删除别名) 1.从数据库删除别名对象数据 2.取出对应的account将别名清除,重新存入数据库 3.重新缓存account rollbackAlias 1.Delete the alias data from the database. 2. Remove the corresponding account to clear the alias and restore it in the database. 3. Recache the account.
 * @param aliasPo
 * @return
 */
public Result rollbackAlias(AliasPo aliasPo){
  try {
    AliasPo po=aliasStorageService.getAlias(aliasPo.getAlias()).getData();
    if (po != null && po.getAddress().equals(aliasPo.getAddress())) {
      aliasStorageService.removeAlias(aliasPo.getAlias());
      AccountPo accountPo=accountStorageService.getAccount(aliasPo.getAddress()).getData();
      accountPo.setAlias("String_Node_Str");
      accountStorageService.updateAccount(accountPo);
      accountCacheService.putAccount(accountPo.toAccount());
    }
  }
 catch (  Exception e) {
    throw new NulsRuntimeException(AccountErrorCode.ALIAS_ROLLBACK_ERROR);
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
/** 
 * 回滚别名操作(删除别名) 1.从数据库删除别名对象数据 2.取出对应的account将别名清除,重新存入数据库 3.重新缓存account rollbackAlias 1.Delete the alias data from the database. 2. Remove the corresponding account to clear the alias and restore it in the database. 3. Recache the account.
 * @param aliasPo
 * @return
 */
public Result rollbackAlias(AliasPo aliasPo) throws NulsException {
  try {
    AliasPo po=aliasStorageService.getAlias(aliasPo.getAlias()).getData();
    if (po != null && Base58.encode(po.getAddress()).equals(Base58.encode(aliasPo.getAddress()))) {
      aliasStorageService.removeAlias(aliasPo.getAlias());
      AccountPo accountPo=accountStorageService.getAccount(aliasPo.getAddress()).getData();
      accountPo.setAlias("String_Node_Str");
      accountStorageService.updateAccount(accountPo);
    }
  }
 catch (  Exception e) {
    Log.error(e);
    throw new NulsException(AccountErrorCode.ALIAS_ROLLBACK_ERROR);
  }
  return Result.getSuccess();
}
Program: 35054
Project: 35054
Buggy source:
@Test public void saveAlias(){
  List<Account> accounts=accountService.createAccount(1,"String_Node_Str").getData();
  Account account=accounts.get(0);
  Alias alias=new Alias(account.getAddress().getBase58Bytes(),"String_Node_Str");
  assertTrue(aliasService.saveAlias(new AliasPo(alias)).isSuccess());
}

Fixed version (ground truth):
@Test public void saveAlias(){
  List<Account> accounts=accountService.createAccount(1,"String_Node_Str").getData();
  Account account=accounts.get(0);
  Alias alias=new Alias(account.getAddress().getBase58Bytes(),"String_Node_Str");
  try {
    assertTrue(aliasService.saveAlias(new AliasPo(alias)).isSuccess());
  }
 catch (  NulsException e) {
    e.printStackTrace();
  }
}
Program: 35055
Project: 35055
Buggy source:
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str",response=Result.class)}) public Result<Boolean> alias(@PathParam("String_Node_Str") String address,@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) AccountAliasForm form){
  if (!Address.validAddress(address)) {
    return Result.getFailed(AccountErrorCode.ADDRESS_ERROR);
  }
  if (StringUtils.isBlank(form.getAlias())) {
    return Result.getFailed(AccountErrorCode.PARAMETER_ERROR);
  }
  if (StringUtils.isNotBlank(form.getPassword()) && !StringUtils.validPassword(form.getPassword())) {
    return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG);
  }
  return aliasService.setAlias(address,form.getPassword(),form.getAlias());
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str",response=Result.class)}) public Result<String> alias(@PathParam("String_Node_Str") String address,@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) AccountAliasForm form){
  if (!Address.validAddress(address)) {
    return Result.getFailed(AccountErrorCode.ADDRESS_ERROR);
  }
  if (StringUtils.isBlank(form.getAlias())) {
    return Result.getFailed(AccountErrorCode.PARAMETER_ERROR);
  }
  if (StringUtils.isNotBlank(form.getPassword()) && !StringUtils.validPassword(form.getPassword())) {
    return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG);
  }
  return aliasService.setAlias(address,form.getPassword(),form.getAlias());
}
Program: 35056
Project: 35056
Buggy source:
@Override public Result updateAccount(AccountPo po){
  AccountPo account=dbService.getModel(AccountStorageConstant.DB_NAME_ACCOUNT,po.getAddressObj().getBase58Bytes(),AccountPo.class);
  if (null == account) {
    return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
  }
  return dbService.putModel(AccountStorageConstant.DB_NAME_ACCOUNT,po.getAddressObj().getBase58Bytes(),po);
}

Fixed version (ground truth):
@Override public Result updateAccount(AccountPo po){
  if (null == po.getAddressObj()) {
    po.setAddressObj(new Address(po.getAddress()));
  }
  AccountPo account=dbService.getModel(AccountStorageConstant.DB_NAME_ACCOUNT,po.getAddressObj().getBase58Bytes(),AccountPo.class);
  if (null == account) {
    return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
  }
  return dbService.putModel(AccountStorageConstant.DB_NAME_ACCOUNT,po.getAddressObj().getBase58Bytes(),po);
}
Program: 35057
Project: 35057
Buggy source:
public Alias(byte[] address,String alias,int status){
  this.address=address;
  this.alias=alias;
  this.status=status;
}

Fixed version (ground truth):
public Alias(byte[] address,String alias){
  this.address=address;
  this.alias=alias;
}
Program: 35058
Project: 35058
Buggy source:
@Override public Result onCommit(RedPunishTransaction tx,Object secondaryData){
  RedPunishData punishData=tx.getTxData();
  BlockHeader header=(BlockHeader)secondaryData;
  BlockRoundData roundData=new BlockRoundData(header.getExtend());
  List<byte[]> savedList=new ArrayList<>();
  PunishLogPo po=new PunishLogPo();
  po.setAddress(punishData.getAddress());
  po.setHeight(tx.getBlockHeight());
  po.setRoundIndex(roundData.getRoundIndex());
  po.setTime(tx.getTime());
  po.setType(PunishType.RED.getCode());
  boolean result=storageService.save(po);
  if (!result) {
    for (    byte[] bytes : savedList) {
      this.storageService.delete(getPoKey(bytes,(byte)PunishType.RED.getCode(),header.getHeight()));
    }
    throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
  }
 else {
    savedList.add(punishData.getAddress());
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
@Override public Result onCommit(RedPunishTransaction tx,Object secondaryData){
  RedPunishData punishData=tx.getTxData();
  BlockHeader header=(BlockHeader)secondaryData;
  BlockRoundData roundData=new BlockRoundData(header.getExtend());
  List<byte[]> savedList=new ArrayList<>();
  PunishLogPo po=new PunishLogPo();
  po.setAddress(punishData.getAddress());
  po.setHeight(tx.getBlockHeight());
  po.setRoundIndex(roundData.getRoundIndex());
  po.setTime(tx.getTime());
  po.setType(PunishType.RED.getCode());
  boolean result=storageService.save(po);
  if (!result) {
    for (    byte[] bytes : savedList) {
      this.storageService.delete(getPoKey(bytes,PunishType.RED.getCode(),header.getHeight()));
    }
    throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
  }
 else {
    savedList.add(punishData.getAddress());
  }
  PocConsensusContext.getChainManager().getMasterChain().getChain().getAgentList();
  return Result.getSuccess();
}
Program: 35059
Project: 35059
Buggy source:
@Override public Result onRollback(RedPunishTransaction tx,Object secondaryData){
  RedPunishData punishData=tx.getTxData();
  List<byte[]> deletedList=new ArrayList<>();
  byte[] address=punishData.getAddress();
  boolean result=storageService.delete(this.getPoKey(address,(byte)PunishType.RED.getCode(),tx.getBlockHeight()));
  if (!result) {
    BlockHeader header=(BlockHeader)secondaryData;
    BlockRoundData roundData=new BlockRoundData(header.getExtend());
    for (    byte[] bytes : deletedList) {
      PunishLogPo po=new PunishLogPo();
      po.setAddress(bytes);
      po.setHeight(tx.getBlockHeight());
      po.setRoundIndex(roundData.getRoundIndex());
      po.setTime(tx.getTime());
      po.setType(PunishType.RED.getCode());
      this.storageService.save(po);
    }
    throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
  }
 else {
    deletedList.add(address);
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
@Override public Result onRollback(RedPunishTransaction tx,Object secondaryData){
  RedPunishData punishData=tx.getTxData();
  List<byte[]> deletedList=new ArrayList<>();
  byte[] address=punishData.getAddress();
  boolean result=storageService.delete(this.getPoKey(address,PunishType.RED.getCode(),tx.getBlockHeight()));
  if (!result) {
    BlockHeader header=(BlockHeader)secondaryData;
    BlockRoundData roundData=new BlockRoundData(header.getExtend());
    for (    byte[] bytes : deletedList) {
      PunishLogPo po=new PunishLogPo();
      po.setAddress(bytes);
      po.setHeight(tx.getBlockHeight());
      po.setRoundIndex(roundData.getRoundIndex());
      po.setTime(tx.getTime());
      po.setType(PunishType.RED.getCode());
      this.storageService.save(po);
    }
    throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
  }
 else {
    deletedList.add(address);
  }
  return Result.getSuccess();
}
Program: 35060
Project: 35060
Buggy source:
@Override public Result onCommit(YellowPunishTransaction tx,Object secondaryData){
  YellowPunishData punishData=tx.getTxData();
  BlockHeader header=(BlockHeader)secondaryData;
  BlockRoundData roundData=new BlockRoundData(header.getExtend());
  List<byte[]> savedList=new ArrayList<>();
  for (  byte[] address : punishData.getAddressList()) {
    PunishLogPo po=new PunishLogPo();
    po.setAddress(address);
    po.setHeight(tx.getBlockHeight());
    po.setRoundIndex(roundData.getRoundIndex());
    po.setTime(tx.getTime());
    po.setType(PunishType.YELLOW.getCode());
    boolean result=storageService.save(po);
    if (!result) {
      for (      byte[] bytes : savedList) {
        this.storageService.delete(getPoKey(bytes,(byte)PunishType.YELLOW.getCode(),header.getHeight()));
      }
      throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
    }
 else {
      savedList.add(address);
    }
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
@Override public Result onCommit(YellowPunishTransaction tx,Object secondaryData){
  YellowPunishData punishData=tx.getTxData();
  BlockHeader header=(BlockHeader)secondaryData;
  BlockRoundData roundData=new BlockRoundData(header.getExtend());
  List<byte[]> savedList=new ArrayList<>();
  for (  byte[] address : punishData.getAddressList()) {
    PunishLogPo po=new PunishLogPo();
    po.setAddress(address);
    po.setHeight(tx.getBlockHeight());
    po.setRoundIndex(roundData.getRoundIndex());
    po.setTime(tx.getTime());
    po.setType(PunishType.YELLOW.getCode());
    boolean result=storageService.save(po);
    if (!result) {
      for (      byte[] bytes : savedList) {
        this.storageService.delete(getPoKey(bytes,PunishType.YELLOW.getCode(),header.getHeight()));
      }
      throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
    }
 else {
      savedList.add(address);
    }
  }
  return Result.getSuccess();
}
Program: 35061
Project: 35061
Buggy source:
@Override public Result onRollback(YellowPunishTransaction tx,Object secondaryData){
  YellowPunishData punishData=tx.getTxData();
  List<byte[]> deletedList=new ArrayList<>();
  for (  byte[] address : punishData.getAddressList()) {
    boolean result=storageService.delete(this.getPoKey(address,(byte)PunishType.YELLOW.getCode(),tx.getBlockHeight()));
    if (!result) {
      BlockHeader header=(BlockHeader)secondaryData;
      BlockRoundData roundData=new BlockRoundData(header.getExtend());
      for (      byte[] bytes : deletedList) {
        PunishLogPo po=new PunishLogPo();
        po.setAddress(bytes);
        po.setHeight(tx.getBlockHeight());
        po.setRoundIndex(roundData.getRoundIndex());
        po.setTime(tx.getTime());
        po.setType(PunishType.YELLOW.getCode());
        this.storageService.save(po);
      }
      throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
    }
 else {
      deletedList.add(address);
    }
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
@Override public Result onRollback(YellowPunishTransaction tx,Object secondaryData){
  YellowPunishData punishData=tx.getTxData();
  List<byte[]> deletedList=new ArrayList<>();
  for (  byte[] address : punishData.getAddressList()) {
    boolean result=storageService.delete(this.getPoKey(address,PunishType.YELLOW.getCode(),tx.getBlockHeight()));
    if (!result) {
      BlockHeader header=(BlockHeader)secondaryData;
      BlockRoundData roundData=new BlockRoundData(header.getExtend());
      for (      byte[] bytes : deletedList) {
        PunishLogPo po=new PunishLogPo();
        po.setAddress(bytes);
        po.setHeight(tx.getBlockHeight());
        po.setRoundIndex(roundData.getRoundIndex());
        po.setTime(tx.getTime());
        po.setType(PunishType.YELLOW.getCode());
        this.storageService.save(po);
      }
      throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
    }
 else {
      deletedList.add(address);
    }
  }
  return Result.getSuccess();
}
Program: 35062
Project: 35062
Buggy source:
/** 
 * 回滚区块 roll back the block to the store.
 * @param block 完整区块/whole block
 * @return 操作结果/operating result
 * @throws NulsException 回滚区块有可能出现异常，请捕获后谨慎处理/There may be exceptions to the roll back block, please handle it carefully after capture.
 */
@Override public Result rollbackBlock(Block block) throws NulsException {
  if (null == block) {
    return Result.getFailed(KernelErrorCode.NULL_PARAMETER);
  }
  this.rollbackTxList(block.getTxs(),block.getHeader());
  BlockHeaderPo po=new BlockHeaderPo();
  po.setHash(block.getHeader().getHash());
  po.setHeight(block.getHeader().getHeight());
  Result result=this.blockHeaderStorageService.removeBlockHerader(po);
  if (result.isFailed()) {
    return result;
  }
  try {
    accountLedgerService.rollback(block.getTxs());
  }
 catch (  Exception e) {
    Log.warn("String_Node_Str",e);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * 回滚区块 roll back the block to the store.
 * @param block 完整区块/whole block
 * @return 操作结果/operating result
 * @throws NulsException 回滚区块有可能出现异常，请捕获后谨慎处理/There may be exceptions to the roll back block, please handle it carefully after capture.
 */
@Override public Result rollbackBlock(Block block) throws NulsException {
  if (null == block) {
    return Result.getFailed(KernelErrorCode.NULL_PARAMETER);
  }
  this.rollbackTxList(block.getTxs(),block.getHeader());
  BlockHeaderPo po=new BlockHeaderPo();
  po.setHash(block.getHeader().getHash());
  po.setHeight(block.getHeader().getHeight());
  po.setPreHash(block.getHeader().getPreHash());
  Result result=this.blockHeaderStorageService.removeBlockHerader(po);
  if (result.isFailed()) {
    return result;
  }
  try {
    accountLedgerService.rollback(block.getTxs());
  }
 catch (  Exception e) {
    Log.warn("String_Node_Str",e);
  }
  return result;
}
Program: 35063
Project: 35063
Buggy source:
/** 
 * 从存储中删除区块头数据 Remove block header data from storage.
 * @param po 区块头,摘要和高度必须要有/Block heads, abstracts and heights must be available.
 * @return 操作结果/operating result
 */
@Override public Result removeBlockHerader(BlockHeaderPo po){
  if (null == po || po.getHeight() < 0 || po.getHash() == null) {
    return Result.getFailed(KernelErrorCode.NULL_PARAMETER);
  }
  dbService.delete(ProtocolStorageConstant.DB_NAME_BLOCK_HEADER_INDEX,new VarInt(po.getHeight()).encode());
  try {
    dbService.put(ProtocolStorageConstant.DB_NAME_BLOCK_HEADER_INDEX,new VarInt(ProtocolStorageConstant.BEST_BLOCK_HASH_INDEX).encode(),po.getPreHash().serialize());
  }
 catch (  IOException e) {
    Log.error(e);
  }
  try {
    return removeBlockHerader(po.getHash().serialize());
  }
 catch (  IOException e) {
    Log.error(e);
    return Result.getFailed(e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * 从存储中删除区块头数据 Remove block header data from storage.
 * @param po 区块头,摘要和高度必须要有/Block heads, abstracts and heights must be available.
 * @return 操作结果/operating result
 */
@Override public Result removeBlockHerader(BlockHeaderPo po){
  if (null == po || po.getHeight() < 0 || po.getHash() == null || po.getPreHash() == null) {
    return Result.getFailed(KernelErrorCode.NULL_PARAMETER);
  }
  dbService.delete(ProtocolStorageConstant.DB_NAME_BLOCK_HEADER_INDEX,new VarInt(po.getHeight()).encode());
  try {
    dbService.put(ProtocolStorageConstant.DB_NAME_BLOCK_HEADER_INDEX,new VarInt(ProtocolStorageConstant.BEST_BLOCK_HASH_INDEX).encode(),po.getPreHash().serialize());
  }
 catch (  IOException e) {
    Log.error(e);
  }
  try {
    return removeBlockHerader(po.getHash().serialize());
  }
 catch (  IOException e) {
    Log.error(e);
    return Result.getFailed(e.getMessage());
  }
}
Program: 35065
Project: 35065
Buggy source:
/** 
 * 冲突检测 1.检测一个acount只能设置一个别名 2.检查是否多个交易设置了同样的别名 conflictDetect 1.Detecting an acount can only set one alias. 2.Check if multiple aliasTransaction have the same alias.
 * @param txList 需要检查的交易列表/A list of transactions to be checked.
 * @return
 */
@Override public ValidateResult conflictDetect(List<Transaction> txList){
  if (null == txList || txList.isEmpty()) {
    return ValidateResult.getSuccessResult();
  }
  Set<String> aliasNames=new HashSet<>();
  Set<String> accountAddress=new HashSet<>();
  for (  Transaction transaction : txList) {
switch (transaction.getType()) {
case AccountConstant.TX_TYPE_ACCOUNT_ALIAS:
      AliasTransaction aliasTransaction=(AliasTransaction)transaction;
    Alias alias=aliasTransaction.getTxData();
  if (!aliasNames.add(alias.getAlias())) {
    return ValidateResult.getFailedResult(getClass().getName(),AccountErrorCode.FAILED,"String_Node_Str");
  }
if (!accountAddress.add(Hex.encode(alias.getAddress()))) {
  return ValidateResult.getFailedResult(getClass().getName(),AccountErrorCode.FAILED,"String_Node_Str");
}
break;
}
}
return ValidateResult.getSuccessResult();
}

Fixed version (ground truth):
/** 
 * 冲突检测 1.检测一个acount只能设置一个别名 2.检查是否多个交易设置了同样的别名 conflictDetect 1.Detecting an acount can only set one alias. 2.Check if multiple aliasTransaction have the same alias.
 * @param txList 需要检查的交易列表/A list of transactions to be checked.
 * @return
 */
@Override public ValidateResult conflictDetect(List<Transaction> txList){
  if (null == txList || txList.isEmpty()) {
    return ValidateResult.getSuccessResult();
  }
  Set<String> aliasNames=new HashSet<>();
  Set<String> accountAddress=new HashSet<>();
  for (  Transaction transaction : txList) {
switch (transaction.getType()) {
case AccountConstant.TX_TYPE_ACCOUNT_ALIAS:
      AliasTransaction aliasTransaction=(AliasTransaction)transaction;
    Alias alias=aliasTransaction.getTxData();
  if (!aliasNames.add(alias.getAlias())) {
    return (ValidateResult)ValidateResult.getFailedResult(getClass().getName(),AccountErrorCode.FAILED,"String_Node_Str").setData(aliasTransaction);
  }
if (!accountAddress.add(Hex.encode(alias.getAddress()))) {
  return (ValidateResult)ValidateResult.getFailedResult(getClass().getName(),AccountErrorCode.FAILED,"String_Node_Str").setData(aliasTransaction);
}
break;
}
}
return ValidateResult.getSuccessResult();
}
Program: 35066
Project: 35066
Buggy source:
@Test public void setPassword(){
}

Fixed version (ground truth):
@Test public void setPassword(){
  List<Account> accounts=this.accountService.createAccount(1,"String_Node_Str").getData();
  Account account=accounts.get(0);
}
Program: 35067
Project: 35067
Buggy source:
@Test public void getPrivateKey(){
  List<Account> accounts=this.accountService.createAccount(1,"String_Node_Str").getData();
  Account account=accounts.get(0);
  Result result=accountBaseService.getPrivateKey(account.getAddress().toString(),"String_Node_Str");
  assertTrue(result.isSuccess());
  try {
    account.unlock("String_Node_Str");
  }
 catch (  NulsException e) {
    e.printStackTrace();
  }
  assertArrayEquals(Hex.decode((String)result.getData()),account.getPriKey());
}

Fixed version (ground truth):
@Test public void getPrivateKey(){
  List<Account> accounts=this.accountService.createAccount(1,"String_Node_Str").getData();
  Account account=accounts.get(0);
  Result result=accountBaseService.getPrivateKey(account.getAddress().toString(),"String_Node_Str");
  assertTrue(result.isSuccess());
  try {
    account.unlock("String_Node_Str");
  }
 catch (  NulsException e) {
    e.printStackTrace();
  }
  assertArrayEquals(Hex.decode((String)result.getData()),account.getPriKey());
  List<Account> accounts2=this.accountService.createAccount(1,"String_Node_Str").getData();
  Account account2=accounts2.get(0);
  Result result2=accountBaseService.getPrivateKey(account2.getAddress().toString(),"String_Node_Str");
  assertTrue(result2.isSuccess());
  assertArrayEquals(Hex.decode((String)result2.getData()),account2.getPriKey());
}
Program: 35068
Project: 35068
Buggy source:
/** 
 * @return
 */
@Override public Result executeBatch(){
  DB db=LevelDBManager.getArea(area);
  if (db == null) {
    return Result.getFailed(DBErrorCode.DB_AREA_NOT_EXIST);
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (    byte[] key : batchDelete) {
      batch.delete(key);
    }
    for (    Entry<byte[],byte[]> entry : batchPut) {
      batch.put(entry.getKey(),entry.getValue());
    }
    db.write(batch);
  }
 catch (  Exception e) {
    Log.error(e);
    return Result.getFailed(KernelErrorCode.DB_UNKOWN_EXCEPTION,e.getMessage());
  }
 finally {
    if (batch != null) {
      try {
        batch.close();
      }
 catch (      IOException e) {
      }
    }
    batchPut.clear();
    batchDelete.clear();
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
/** 
 * @return
 */
@Override public Result executeBatch(){
  DB db=LevelDBManager.getArea(area);
  if (db == null) {
    return Result.getFailed(DBErrorCode.DB_AREA_NOT_EXIST);
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    byte[] key=null, value=null;
    for (    Entry<byte[],byte[]> entry : batchList) {
      key=entry.getKey();
      value=entry.getValue();
      if (value == null) {
        batch.delete(key);
      }
 else {
        batch.put(key,value);
      }
    }
    db.write(batch);
  }
 catch (  Exception e) {
    Log.error(e);
    return Result.getFailed(KernelErrorCode.DB_UNKOWN_EXCEPTION,e.getMessage());
  }
 finally {
    if (batch != null) {
      try {
        batch.close();
      }
 catch (      IOException e) {
      }
    }
    batchList.clear();
  }
  return Result.getSuccess();
}
Program: 35069
Project: 35069
Buggy source:
/** 
 * @param key
 * @return
 */
@Override public Result delete(byte[] key){
  if (key == null) {
    return Result.getFailed(KernelErrorCode.NULL_PARAMETER);
  }
  batchDelete.add(key);
  return Result.getSuccess();
}

Fixed version (ground truth):
/** 
 * @param key
 * @return
 */
@Override public Result delete(byte[] key){
  if (key == null) {
    return Result.getFailed(KernelErrorCode.NULL_PARAMETER);
  }
  batchList.add(Maps.immutableEntry(key,(byte[])null));
  return Result.getSuccess();
}
Program: 35070
Project: 35070
Buggy source:
/** 
 * @param key
 * @param value
 * @return
 */
@Override public Result put(byte[] key,byte[] value){
  if (key == null || value == null) {
    return Result.getFailed(KernelErrorCode.NULL_PARAMETER);
  }
  batchPut.add(Maps.immutableEntry(key,value));
  return Result.getSuccess();
}

Fixed version (ground truth):
/** 
 * @param key
 * @param value
 * @return
 */
@Override public Result put(byte[] key,byte[] value){
  if (key == null || value == null) {
    return Result.getFailed(KernelErrorCode.NULL_PARAMETER);
  }
  batchList.add(Maps.immutableEntry(key,value));
  return Result.getSuccess();
}
Program: 35071
Project: 35071
Buggy source:
private Result saveCoinData(Transaction tx) throws IOException {
  byte[] txHashBytes=txHashBytes=tx.getHash().serialize();
  BatchOperation batch=utxoLedgerUtxoStorageService.createWriteBatch();
  CoinData coinData=tx.getCoinData();
  if (coinData != null) {
    List<Coin> froms=coinData.getFrom();
    for (    Coin from : froms) {
      batch.delete(from.getOwner());
    }
    List<Coin> tos=coinData.getTo();
    byte[] indexBytes;
    for (int i=0, length=tos.size(); i < length; i++) {
      try {
        batch.put(Arrays.concatenate(txHashBytes,new VarInt(i).encode()),tos.get(i).serialize());
      }
 catch (      IOException e) {
        Log.error(e);
        return Result.getFailed(e.getMessage());
      }
    }
    Result batchResult=batch.executeBatch();
    if (batchResult.isFailed()) {
      return batchResult;
    }
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
private Result saveCoinData(Transaction tx) throws IOException {
  byte[] txHashBytes=tx.getHash().serialize();
  BatchOperation batch=utxoLedgerUtxoStorageService.createWriteBatch();
  CoinData coinData=tx.getCoinData();
  Log.info("String_Node_Str" + tx.getClass().getSimpleName() + "String_Node_Str"+ tx.getHash().getDigestHex());
  if (coinData != null) {
    List<Coin> froms=coinData.getFrom();
    for (    Coin from : froms) {
      Coin preFrom=utxoLedgerUtxoStorageService.getUtxo(from.getOwner());
      if (preFrom != null)       Log.info("String_Node_Str" + tx.getClass().getSimpleName() + "String_Node_Str"+ Base58.encode(preFrom.getOwner())+ "String_Node_Str"+ preFrom.getNa().getValue());
      batch.delete(from.getOwner());
    }
    List<Coin> tos=coinData.getTo();
    byte[] indexBytes;
    for (int i=0, length=tos.size(); i < length; i++) {
      try {
        Coin to=tos.get(i);
        Log.info("String_Node_Str" + tx.getClass().getSimpleName() + "String_Node_Str"+ Base58.encode(to.getOwner())+ "String_Node_Str"+ to.getNa().getValue());
        batch.put(Arrays.concatenate(txHashBytes,new VarInt(i).encode()),tos.get(i).serialize());
      }
 catch (      IOException e) {
        Log.error(e);
        return Result.getFailed(e.getMessage());
      }
    }
    Result batchResult=batch.executeBatch();
    if (batchResult.isFailed()) {
      return batchResult;
    }
  }
  return Result.getSuccess();
}
Program: 35072
Project: 35072
Buggy source:
@Override public Result saveTx(Transaction tx) throws NulsException {
  if (tx == null) {
    return Result.getFailed(LedgerErrorCode.NULL_PARAMETER);
  }
  try {
    Result result=saveCoinData(tx);
    if (result.isFailed()) {
      Result rollbackResult=rollbackCoinData(tx);
      if (rollbackResult.isFailed()) {
        throw new NulsException(LedgerErrorCode.DB_ROLLBACK_ERROR,CLASS_NAME + "String_Node_Str");
      }
      return result;
    }
    result=utxoLedgerTransactionStorageService.saveTx(tx);
    if (result.isFailed()) {
      Result rollbackResult=rollbackTx(tx);
      if (rollbackResult.isFailed()) {
        throw new NulsException(LedgerErrorCode.DB_ROLLBACK_ERROR,CLASS_NAME + "String_Node_Str");
      }
    }
    return result;
  }
 catch (  IOException e) {
    Log.error(e);
    Result rollbackResult=rollbackTx(tx);
    if (rollbackResult.isFailed()) {
      throw new NulsException(LedgerErrorCode.DB_ROLLBACK_ERROR,CLASS_NAME + "String_Node_Str");
    }
    return Result.getFailed(e.getMessage());
  }
}

Fixed version (ground truth):
@Override public Result saveTx(Transaction tx) throws NulsException {
  if (tx == null) {
    return Result.getFailed(LedgerErrorCode.NULL_PARAMETER);
  }
  try {
    if ("String_Node_Str".equals(tx.getClass().getName())) {
      Log.info("String_Node_Str");
    }
    Result result=saveCoinData(tx);
    if (result.isFailed()) {
      Result rollbackResult=rollbackCoinData(tx);
      if (rollbackResult.isFailed()) {
        throw new NulsException(LedgerErrorCode.DB_ROLLBACK_ERROR,CLASS_NAME + "String_Node_Str");
      }
      return result;
    }
    result=utxoLedgerTransactionStorageService.saveTx(tx);
    if (result.isFailed()) {
      Result rollbackResult=rollbackTx(tx);
      if (rollbackResult.isFailed()) {
        throw new NulsException(LedgerErrorCode.DB_ROLLBACK_ERROR,CLASS_NAME + "String_Node_Str");
      }
    }
    return result;
  }
 catch (  IOException e) {
    Log.error(e);
    Result rollbackResult=rollbackTx(tx);
    if (rollbackResult.isFailed()) {
      throw new NulsException(LedgerErrorCode.DB_ROLLBACK_ERROR,CLASS_NAME + "String_Node_Str");
    }
    return Result.getFailed(e.getMessage());
  }
}
Program: 35074
Project: 35074
Buggy source:
private Result rollbackCoinData(Transaction tx) throws IOException {
  byte[] txHashBytes=txHashBytes=tx.getHash().serialize();
  BatchOperation batch=utxoLedgerUtxoStorageService.createWriteBatch();
  CoinData coinData=tx.getCoinData();
  if (coinData != null) {
    List<Coin> froms=coinData.getFrom();
    for (    Coin from : froms) {
      try {
        batch.put(from.getOwner(),from.serialize());
      }
 catch (      IOException e) {
        Log.error(e);
        return Result.getFailed(e.getMessage());
      }
    }
    List<Coin> tos=coinData.getTo();
    byte[] indexBytes;
    for (int i=0, length=tos.size(); i < length; i++) {
      batch.delete(Arrays.concatenate(txHashBytes,new VarInt(i).encode()));
    }
    Result batchResult=batch.executeBatch();
    if (batchResult.isFailed()) {
      return batchResult;
    }
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
private Result rollbackCoinData(Transaction tx) throws IOException, NulsException {
  byte[] txHashBytes=txHashBytes=tx.getHash().serialize();
  BatchOperation batch=utxoLedgerUtxoStorageService.createWriteBatch();
  CoinData coinData=tx.getCoinData();
  P2PKHScriptSig p2PKHScriptSig=P2PKHScriptSig.createFromBytes(tx.getScriptSig());
  if (coinData != null) {
    List<Coin> froms=coinData.getFrom();
    Coin recovery;
    byte[] fromAdress=AddressTool.getAddress(p2PKHScriptSig.getPublicKey());
    for (    Coin from : froms) {
      try {
        recovery=new Coin(fromAdress,from.getNa(),from.getLockTime());
        recovery.setFrom(from.getFrom());
        batch.put(from.getOwner(),recovery.serialize());
      }
 catch (      IOException e) {
        Log.error(e);
        return Result.getFailed(e.getMessage());
      }
    }
    List<Coin> tos=coinData.getTo();
    byte[] indexBytes;
    for (int i=0, length=tos.size(); i < length; i++) {
      batch.delete(Arrays.concatenate(txHashBytes,new VarInt(i).encode()));
    }
    Result batchResult=batch.executeBatch();
    if (batchResult.isFailed()) {
      return batchResult;
    }
  }
  return Result.getSuccess();
}
Program: 35077
Project: 35077
Buggy source:
/** 
 * @return
 */
@Override public Result executeBatch(){
  DB db=LevelDBManager.getArea(area);
  if (db == null) {
    return Result.getFailed(DBErrorCode.DB_AREA_NOT_EXIST);
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (    Entry<byte[],byte[]> entry : batchPut) {
      batch.put(entry.getKey(),entry.getValue());
    }
    for (    byte[] key : batchDelete) {
      batch.delete(key);
    }
    db.write(batch);
  }
 catch (  Exception e) {
    Log.error(e);
    return Result.getFailed(KernelErrorCode.DB_UNKOWN_EXCEPTION,e.getMessage());
  }
 finally {
    if (batch != null) {
      try {
        batch.close();
      }
 catch (      IOException e) {
      }
    }
    batchPut.clear();
    batchDelete.clear();
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
/** 
 * @return
 */
@Override public Result executeBatch(){
  DB db=LevelDBManager.getArea(area);
  if (db == null) {
    return Result.getFailed(DBErrorCode.DB_AREA_NOT_EXIST);
  }
  WriteBatch batch=null;
  try {
    batch=db.createWriteBatch();
    for (    byte[] key : batchDelete) {
      batch.delete(key);
    }
    for (    Entry<byte[],byte[]> entry : batchPut) {
      batch.put(entry.getKey(),entry.getValue());
    }
    db.write(batch);
  }
 catch (  Exception e) {
    Log.error(e);
    return Result.getFailed(KernelErrorCode.DB_UNKOWN_EXCEPTION,e.getMessage());
  }
 finally {
    if (batch != null) {
      try {
        batch.close();
      }
 catch (      IOException e) {
      }
    }
    batchPut.clear();
    batchDelete.clear();
  }
  return Result.getSuccess();
}
Program: 35078
Project: 35078
Buggy source:
/** 
 * Check whether every from one in the coinData exists in txList database, or if not, is to continue to check the from of the existence of the deal and if it exists, represents a double spend, does not exist, is the orphan transactions, finally throw an exception 检查coinData里的每一笔from是否存在于txList或者数据库中，如果不存在，则继续检查from中那笔交易是否存在，如果存在，则代表双花，不存在，则是孤儿交易，最后抛出异常
 * @param coinData
 * @param txList
 * @return
 */
ValidateResult verifyCoinData(CoinData coinData,List<Transaction> txList);

Fixed version (ground truth):
/** 
 * Verify that a coindata is valid, the first verification owner is legal (whether it can be used), the second verification amount is correct (output can not be greater than the input) Check whether every from one in the coinData exists in txList database, or if not, is to continue to check the from of the existence of the deal and if it exists, represents a double spend, does not exist, is the orphan transactions, finally throw an exception 验证一笔coindata是否合法，验证拥有者是否合法（是否可动用），验证金额是否正确（输出不能大于输入） 检查coinData里的每一笔from是否存在于txList或者数据库中，如果不存在，则继续检查from中那笔交易是否存在，如果存在，则代表双花，不存在，则是孤儿交易，最后抛出异常
 * @param transaction
 * @param txList
 * @return
 */
ValidateResult verifyCoinData(Transaction transaction,List<Transaction> txList);
Program: 35079
Project: 35079
Buggy source:
protected Result<Integer> saveConfirmedTransaction(Transaction tx,byte[] addresss,byte status){
  List<byte[]> destAddresses=new ArrayList<byte[]>();
  destAddresses.add(addresss);
  List<byte[]> addresses=getRelatedAddresses(tx,destAddresses);
  if (addresses == null || addresses.size() == 0) {
    return Result.getFailed().setData(new Integer(0));
  }
  TransactionInfoPo txInfoPo=new TransactionInfoPo(tx);
  txInfoPo.setStatus(status);
  Result result=storageService.saveLocalTxInfo(txInfoPo,addresses);
  if (result.isFailed()) {
    return result;
  }
  result=storageService.saveLocalTx(tx);
  if (result.isFailed()) {
    storageService.deleteLocalTxInfo(txInfoPo);
  }
  return result;
}

Fixed version (ground truth):
@Override public Result<Integer> saveConfirmedTransaction(Transaction tx){
  return saveTransaction(tx,TransactionInfo.CONFIRMED);
}
Program: 35080
Project: 35080
Buggy source:
@Override public Result<Integer> saveUnconfirmedTransaction(Transaction tx){
  return saveConfirmedTransaction(tx,TransactionInfo.UNCONFIRMED);
}

Fixed version (ground truth):
@Override public Result<Integer> saveUnconfirmedTransaction(Transaction tx){
  return saveTransaction(tx,TransactionInfo.UNCONFIRMED);
}
Program: 35081
Project: 35081
Buggy source:
@Override public Result importAccountLedger(String address){
  if (address == null || !Address.validAddress(address)) {
    return Result.getFailed(AccountLedgerErrorCode.ADDRESS_ERROR);
  }
  byte[] addressBytes=null;
  try {
    addressBytes=Base58.decode(address);
  }
 catch (  Exception e) {
    return Result.getFailed(AccountLedgerErrorCode.ADDRESS_ERROR);
  }
  reloadAccount();
  long height=NulsContext.getInstance().getBestHeight();
  for (int i=0; i <= height; i++) {
    List<NulsDigestData> txs=blockService.getBlock(i).getData().getTxHashList();
    for (int j=0; j < txs.size(); j++) {
      Transaction tx=ledgerService.getTx(txs.get(j));
      saveConfirmedTransaction(tx,addressBytes,TransactionInfo.CONFIRMED);
    }
  }
  try {
    balanceProvider.refreshBalance(addressBytes);
  }
 catch (  Exception e) {
    Log.info(address);
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
@Override public Result importAccountLedger(String address){
  if (address == null || !Address.validAddress(address)) {
    return Result.getFailed(AccountLedgerErrorCode.ADDRESS_ERROR);
  }
  byte[] addressBytes=null;
  try {
    addressBytes=Base58.decode(address);
  }
 catch (  Exception e) {
    return Result.getFailed(AccountLedgerErrorCode.ADDRESS_ERROR);
  }
  reloadAccount();
  long height=NulsContext.getInstance().getBestHeight();
  for (int i=0; i <= height; i++) {
    List<NulsDigestData> txs=blockService.getBlock(i).getData().getTxHashList();
    for (int j=0; j < txs.size(); j++) {
      Transaction tx=ledgerService.getTx(txs.get(j));
      saveTransaction(tx,addressBytes,TransactionInfo.CONFIRMED);
    }
  }
  try {
    balanceProvider.refreshBalance(addressBytes);
  }
 catch (  Exception e) {
    Log.info(address);
  }
  return Result.getSuccess();
}