Skip to content

Commit

Permalink
Accepting HTLC when the balance is insufficient
Browse files Browse the repository at this point in the history
  • Loading branch information
obdCoder committed Feb 16, 2022
1 parent cb29805 commit 35c9288
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lightclient/wsclient_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (client *Client) UserModule(msg bean.RequestMessage) (enum.SendTargetType,
isAdmin := false

//TODO 管理员验证
if client.IsGRpcRequest || true {
if client.IsGRpcRequest {
loginToken := gjson.Get(msg.Data, "login_token").Str
isAdmin = service.CheckIsAdmin(loginToken)
}
Expand All @@ -47,6 +47,7 @@ func (client *Client) UserModule(msg bean.RequestMessage) (enum.SendTargetType,
peerId = tool.GetUserPeerId(mnemonic)
} else {
peerId = tool.GetUserPeerId(walletId)
//peerId = tool.GetUserPeerId(mnemonic)
}
if GlobalWsClientManager.OnlineClientMap[peerId] != nil {
if GlobalWsClientManager.OnlineClientMap[peerId].User.IsAdmin {
Expand Down
5 changes: 5 additions & 0 deletions service/htlc_tx_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ func (service *htlcForwardTxManager) AliceAddHtlcAtAliceSide(msg bean.RequestMes
}
latestCommitmentTx, _ = getLatestCommitmentTxUseDbTx(tx, channelInfo.ChannelId, user.PeerId)

// Accepting HTLC when the balance is insufficient
if latestCommitmentTx.AmountToRSMC < requestData.AmountToPayee {
return nil, false, errors.New(fmt.Sprintf("The amountToPayee in transaction must be more than %.8f", latestCommitmentTx.AmountToRSMC))
}

if latestCommitmentTx.Id > 0 {
if latestCommitmentTx.CurrState == dao.TxInfoState_CreateAndSign {
_, err = omnicore.GetPubKeyFromWifAndCheck(requestData.LastTempAddressPrivateKey, latestCommitmentTx.RSMCTempAddressPubKey)
Expand Down

0 comments on commit 35c9288

Please sign in to comment.