예제 #1
0
Value marketrequestpayment(const Array& params, bool fHelp)
{
    if (fHelp || params.size() == 0)
        throw runtime_error("marketrequestpayment ListingID \n"
                            "Request a payment for a market item \n"
                            "parameters: <requestId>");

    string requestID = params[0].get_str();

    uint256 requestHashId = uint256(requestID);
    uint256 listingHashId = mapBuyRequests[requestHashId].listingId;

    CPaymentRequest request;
    request.listingId = listingHashId;
    request.requestId = requestHashId;
    request.nDate = GetTime();
    request.sellerKey = pwalletMain->GenerateNewKey();

    CBuyRequest buyRequest = mapBuyRequests[requestHashId];

    std::string rawTx = PayEscrow(buyRequest.buyerEscrowLockTxHash, buyRequest.sellerEscrowLockTxHash, mapListings[buyRequest.listingId].listing.sellerKey, 2*mapListings[buyRequest.listingId].listing.nPrice);

    request.rawTx = rawTx;
    SignPaymentRequest(request, request.vchSig);
    ReceivePaymentRequest(request);
    request.BroadcastToAll();

    return Value::null;
}
예제 #2
0
void SellsPage::on_requestPaymentButton_clicked()
{
    QItemSelectionModel* selectionModel = ui->buysTableWidget->selectionModel();
    QModelIndexList selected = selectionModel->selectedRows();
    if(selected.count() == 0)
        return;

    QModelIndex index = selected.at(0);
    int r = index.row();
    std::string id = ui->buysTableWidget->item(r, 4)->text().toStdString();
    uint256 listingIdHash = uint256(id);
    std::string rid = ui->buysTableWidget->item(r, 5)->text().toStdString();
    uint256 requestIdHash = uint256(rid);

    // ask the user if they really want to accept the buy request
    QMessageBox::StandardButton reply;
      reply = QMessageBox::question(this, "Request Payment", "Are you sure you want to request payment for this item?",
                                QMessageBox::Yes|QMessageBox::No);
    if (reply == QMessageBox::Yes) 
    {
        CPaymentRequest request;
	request.listingId = listingIdHash;
	request.requestId = requestIdHash;
	request.nDate = GetTime();
	request.sellerKey = pwalletMain->GenerateNewKey();

        CBuyRequest buyRequest = mapBuyRequests[requestIdHash];

	std::string rawTx = PayEscrow(buyRequest.buyerEscrowLockTxHash, buyRequest.sellerEscrowLockTxHash, mapListings[buyRequest.listingId].listing.sellerKey, 2*mapListings[buyRequest.listingId].listing.nPrice);

	request.rawTx = rawTx;	
	LogPrintf("Request Payment: rawtx: %s\n", rawTx);
	SignPaymentRequest(request, request.vchSig);
	ReceivePaymentRequest(request);
	request.BroadcastToAll();
	LoadSells();
	LoadBuyRequests();
    }
}